Instance attribute attribute_name defined outside __init__

I split up my class constructor by letting it call multiple functions, like this: class Wizard: def __init__(self, argv): self.parse_arguments(argv) self.wave_wand() # declaration omitted def parse_arguments(self, argv): if self.has_correct_argument_count(argv): self.name = argv[0] self.magic_ability = argv[1] else: raise InvalidArgumentsException() # declaration omitted # … irrelevant functions omitted While my interpreter happily runs my code, Pylint has … Read more

Pylint “unresolved import” error in Visual Studio Code

I am using the following setup macOS v10.14 (Mojave) Python 3.7.1 Visual Studio Code 1.30 Pylint 2.2.2 Django 2.1.4 I want to use linting to make my life a bit easier in Visual Studio Code. However, for every import I have states “unresolved import”. Even on default Django imports (i.e. from django.db import models). I … Read more

Why is the use of len(SEQUENCE) in condition values considered incorrect by Pylint?

Considering this code snippet: from os import walk files = [] for (dirpath, _, filenames) in walk(mydir): # More code that modifies files if len(files) == 0: # <– C1801 return None I was alarmed by Pylint with this message regarding the line with the if statement: [pylint] C1801:Do not use len(SEQUENCE) as condition value … Read more

Is it possible to ignore one single specific line with Pylint?

I have the following line in my header: import config.logging_settings This actually changes my Python logging settings, but Pylint thinks it is an unused import. I do not want to remove unused-import warnings in general, so is it possible to just ignore this one specific line? I wouldn’t mind having a .pylintrc for this project, … Read more

PyLint message: logging-format-interpolation

For the following code: logger.debug(‘message: {}’.format(‘test’)) pylint produces the following warning: logging-format-interpolation (W1202): Use % formatting in logging functions and pass the % parameters as arguments Used when a logging statement has a call form of “logging.(format_string.format(format_args…))”. Such calls should use % formatting instead, but leave interpolation to the logging function by passing the parameters … Read more

PyLint “Unable to import” error – how to set PYTHONPATH?

I’m running PyLint from inside Wing IDE on Windows. I have a sub-directory (package) in my project and inside the package I import a module from the top level, ie. __init__.py myapp.py one.py subdir\ __init__.py two.py Inside two.py I have import one and this works fine at runtime, because the top-level directory (from which myapp.py … Read more

Pylint, PyChecker or PyFlakes? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for … Read more