From 12f309f2dc7d22359404e7041e4f044441652c54 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 9 Oct 2024 21:35:05 +0200 Subject: [PATCH] [ruff] Activate ruff's pylint messages --- pylint_django/augmentations/__init__.py | 13 ++++++------- pylint_django/checkers/models.py | 2 +- pyproject.toml | 9 ++++++++- 3 files changed, 15 insertions(+), 9 deletions(-) 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/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/pyproject.toml b/pyproject.toml index ca879b4..0f25404 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,7 +74,11 @@ lint.select = [ "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 @@ -82,7 +86,10 @@ lint.select = [ "W", # pycodestyle ] lint.ignore = [ - "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` + "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]