diff --git a/pylint_django/augmentations/__init__.py b/pylint_django/augmentations/__init__.py index 1ff4c41..a5eef37 100644 --- a/pylint_django/augmentations/__init__.py +++ b/pylint_django/augmentations/__init__.py @@ -366,12 +366,11 @@ class ModelB(models.Model): # if this is a X_set method, that's a pretty strong signal that this is the default # Django name, rather than one set by related_name quack = True - else: - # we will - if isinstance(node.parent, Attribute): - func_name = getattr(node.parent, "attrname", None) - if func_name in MANAGER_ATTRS: - quack = True + # we will + elif isinstance(node.parent, Attribute): + func_name = getattr(node.parent, "attrname", None) + if func_name in MANAGER_ATTRS: + quack = True if quack: children = list(node.get_children()) @@ -522,7 +521,7 @@ def _attribute_is_magic(node, attrs, parents): try: for cls in node.last_child().inferred(): if isinstance(cls, Super): - cls = cls._self_class # pylint: disable=protected-access + cls = cls._self_class # pylint: disable=protected-access # noqa:PLW2901 if node_is_subclass(cls, *parents) or cls.qname() in parents: return True except InferenceError: diff --git a/pylint_django/checkers/foreign_key_strings.py b/pylint_django/checkers/foreign_key_strings.py index bb61b72..20b102e 100644 --- a/pylint_django/checkers/foreign_key_strings.py +++ b/pylint_django/checkers/foreign_key_strings.py @@ -83,7 +83,8 @@ def open(self): import django # pylint: disable=import-outside-toplevel django.setup() - from django.apps import apps # noqa pylint: disable=import-outside-toplevel,unused-import + # pylint: disable-next=import-outside-toplevel,unused-import + from django.apps import apps # noqa: F401 except ImproperlyConfigured: # this means that Django wasn't able to configure itself using some defaults diff --git a/pylint_django/checkers/models.py b/pylint_django/checkers/models.py index 76a6b9f..7ff130a 100644 --- a/pylint_django/checkers/models.py +++ b/pylint_django/checkers/models.py @@ -79,7 +79,7 @@ class ModelChecker(BaseChecker): msgs = MESSAGES @check_messages("model-missing-unicode") - def visit_classdef(self, node): + def visit_classdef(self, node): # noqa: PLR0911 """Class visitor.""" if not node_is_subclass(node, "django.db.models.base.Model", ".Model"): # we only care about models diff --git a/pylint_django/tests/test_func.py b/pylint_django/tests/test_func.py index 2c444e8..51cfc6f 100644 --- a/pylint_django/tests/test_func.py +++ b/pylint_django/tests/test_func.py @@ -54,7 +54,7 @@ def __init__(self, test_file): # if hasattr(test_file, 'option_file') and test_file.option_file is None: # pylint: disable=super-with-arguments # TODO Fix this and the CI (?) - super(PylintDjangoLintModuleTest, self).__init__(test_file) # noqa + super(PylintDjangoLintModuleTest, self).__init__(test_file) # noqa: UP008 self._linter.load_plugin_modules(["pylint_django"]) self._linter.load_plugin_configuration() diff --git a/pyproject.toml b/pyproject.toml index 82b8fc7..0f25404 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,17 +66,30 @@ line-length = 120 [tool.ruff] line-length = 120 -select = [ - "E", # pycodestyle - "F", # pyflakes - "W", # pycodestyle - "B", # bugbear - "I", # isort - "RUF", # ruff - "UP", # pyupgrade +lint.select = [ + "B", # bugbear + "E", # pycodestyle + "F", # pyflakes + "FA100", # add future annotations + "I", # isort + "PGH004", # pygrep-hooks - Use specific rule codes when using noqa + "PIE", # flake8-pie + "PLC", # pylint convention + "PLE", # pylint error + "PLR", # pylint refactor + "PLR1714", # Consider merging multiple comparisons + "PLW", # pylint warning + "PYI", # flake8-pyi + "RUF", # ruff + "T100", # flake8-debugger + "UP", # pyupgrade + "W", # pycodestyle ] -ignore = [ - "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` +lint.ignore = [ + "PLR0912", # Too many branches, worse than C901 + "PLR0915", # Too many statements, worse than C901 + "PLR2004", # Magic value used in comparison, opinionated + "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` ] [tool.isort]