Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pylint-django to 2.5.5 #3393

Merged
merged 4 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions kiwi_lint/api_distinct.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright (c) 2021 Alexander Todorov <[email protected]>
# Copyright (c) 2021,2023 Alexander Todorov <[email protected]>

# Licensed under the GPL 2.0: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html

from pylint import checkers, interfaces
from pylint import checkers

from .utils import is_api_function

Expand All @@ -15,8 +15,6 @@ class APIDistinctChecker(checkers.BaseChecker):
current_api_method = None
distinct_found = False

__implements__ = (interfaces.IAstroidChecker,)

name = "api-distinct-checker"

msgs = {
Expand Down
6 changes: 2 additions & 4 deletions kiwi_lint/auto_field.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from pylint import checkers, interfaces
from pylint import checkers
from pylint.checkers import utils


class AutoFieldChecker(checkers.BaseChecker):
__implements__ = (interfaces.IAstroidChecker,)

name = "auto-field-checker"

msgs = {
Expand All @@ -15,7 +13,7 @@ class AutoFieldChecker(checkers.BaseChecker):
)
}

@utils.check_messages("avoid-auto-field")
@utils.only_required_for_messages("avoid-auto-field")
def visit_attribute(self, node):
if node.attrname == "AutoField":
self.add_message("avoid-auto-field", node=node)
8 changes: 3 additions & 5 deletions kiwi_lint/bulk_create.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Copyright (c) 2018 Alexander Todorov <[email protected]>
# Copyright (c) 2018,2023 Alexander Todorov <[email protected]>

# Licensed under the GPL 2.0: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html

from pylint import checkers, interfaces
from pylint import checkers
from pylint.checkers import utils


class BulkCreateChecker(checkers.BaseChecker):
__implements__ = (interfaces.IAstroidChecker,)

name = "bulk-create-checker"

msgs = {
Expand All @@ -20,7 +18,7 @@ class BulkCreateChecker(checkers.BaseChecker):
)
}

@utils.check_messages("bulk-create-used")
@utils.only_required_for_messages("bulk-create-used")
def visit_attribute(self, node):
if node.attrname == "bulk_create":
self.add_message("bulk-create-used", node=node)
4 changes: 1 addition & 3 deletions kiwi_lint/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
"""

from astroid import nodes
from pylint import checkers, interfaces
from pylint import checkers


class DatetimeChecker(checkers.BaseChecker):
__implements__ = (interfaces.IAstroidChecker,)

name = "datetime-checker"

msgs = {
Expand Down
6 changes: 2 additions & 4 deletions kiwi_lint/db_column.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from pylint import checkers, interfaces
from pylint import checkers
from pylint.checkers import utils


class DbColumnChecker(checkers.BaseChecker):
__implements__ = (interfaces.IAstroidChecker,)

name = "db-column-used"

msgs = {
Expand All @@ -16,7 +14,7 @@ class DbColumnChecker(checkers.BaseChecker):
)
}

@utils.check_messages("db-column-used")
@utils.only_required_for_messages("db-column-used")
def visit_keyword(self, node):
if node.arg == "db_column":
self.add_message("db-column-used", node=node)
15 changes: 5 additions & 10 deletions kiwi_lint/docstring.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
# Copyright (c) 2018 Alexander Todorov <[email protected]>
# Copyright (c) 2018,2023 Alexander Todorov <[email protected]>

# Licensed under the GPL 2.0: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html

import tokenize

from pylint import checkers, interfaces
from pylint import checkers
from pylint.checkers import utils


class DocstringChecker(checkers.BaseTokenChecker):
__implements__ = (
interfaces.ITokenChecker,
interfaces.IAstroidChecker,
)

name = "docstring-checker"

msgs = {
Expand Down Expand Up @@ -61,9 +56,9 @@ def visit_classdef(self, node):
def visit_functiondef(self, node):
self._check_docstring(node)

@utils.check_messages("use-triple-double-quotes")
@utils.only_required_for_messages("use-triple-double-quotes")
def _check_docstring(self, node):
if node.doc in self._string_tokens:
token = self._string_tokens[node.doc]
if node.doc_node and node.doc_node.value in self._string_tokens:
token = self._string_tokens[node.doc_node.value]
if not token.startswith('"""'):
self.add_message("use-triple-double-quotes", node=node)
8 changes: 3 additions & 5 deletions kiwi_lint/dunder_attributes.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Copyright (c) 2018 Alexander Todorov <[email protected]>
# Copyright (c) 2018,2023 Alexander Todorov <[email protected]>

# Licensed under the GPL 2.0: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html

import astroid
from pylint import checkers, interfaces
from pylint import checkers
from pylint.checkers import utils


class DunderClassAttributeChecker(checkers.BaseChecker):
__implements__ = (interfaces.IAstroidChecker,)

name = "dunder-class-attribute-checker"

msgs = {
Expand All @@ -21,7 +19,7 @@ class DunderClassAttributeChecker(checkers.BaseChecker):
)
}

@utils.check_messages("dunder-class-attribute")
@utils.only_required_for_messages("dunder-class-attribute")
def visit_classdef(self, node):
"""Detect when class attributes use double underscores."""
# we can redefine special methods (e.g. __iter__) and some attributes,
Expand Down
16 changes: 5 additions & 11 deletions kiwi_lint/empty.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# Copyright (c) 2018 Alexander Todorov <[email protected]>
# Copyright (c) 2018,2023 Alexander Todorov <[email protected]>

# Licensed under the GPL 2.0: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html

import os

import astroid
from pylint import checkers, interfaces
from pylint import checkers
from pylint.checkers import utils


class EmptyModuleChecker(checkers.BaseChecker):
__implements__ = (interfaces.IAstroidChecker,)

name = "empty-module-checker"

msgs = {
Expand All @@ -23,15 +21,13 @@ class EmptyModuleChecker(checkers.BaseChecker):
)
}

@utils.check_messages("remove-empty-module")
@utils.only_required_for_messages("remove-empty-module")
def visit_module(self, node):
if not node.body and not node.path[0].endswith("__init__.py"):
self.add_message("remove-empty-module", node=node)


class ModuleInDirectoryWithoutInitChecker(checkers.BaseChecker):
__implements__ = (interfaces.IAstroidChecker,)

name = "dir-without-init-checker"

msgs = {
Expand Down Expand Up @@ -73,7 +69,7 @@ def visit_module(self, node):
for file_name in node.path:
self.discovered_python_files.add(file_name)

@utils.check_messages("module-in-directory-without-init")
@utils.only_required_for_messages("module-in-directory-without-init")
def close(self):
diff = self.all_python_files - self.discovered_python_files
diff = list(diff)
Expand All @@ -86,8 +82,6 @@ def close(self):


class EmptyClassChecker(checkers.BaseChecker):
__implements__ = (interfaces.IAstroidChecker,)

name = "empty-class-checker"

msgs = {
Expand All @@ -99,7 +93,7 @@ class EmptyClassChecker(checkers.BaseChecker):
)
}

@utils.check_messages("remove-empty-class")
@utils.only_required_for_messages("remove-empty-class")
def visit_classdef(self, node):
if not node.body:
self.add_message("remove-empty-class", node=node)
Expand Down
6 changes: 1 addition & 5 deletions kiwi_lint/forms.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from pylint import checkers, interfaces
from pylint import checkers
from pylint_django.utils import node_is_subclass


class FormFieldChecker(checkers.BaseChecker):
__implements__ = (interfaces.IAstroidChecker,)

name = "form-field-label-checker"

msgs = {
Expand Down Expand Up @@ -38,8 +36,6 @@ class ModelFormChecker(checkers.BaseChecker):
Check to ensure that all forms inherit from ModelForm.
"""

__implements__ = (interfaces.IAstroidChecker,)

name = "model-form-checker"

msgs = {
Expand Down
5 changes: 1 addition & 4 deletions kiwi_lint/generic_foreign_key.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import astroid
from pylint.checkers import BaseChecker, utils
from pylint.interfaces import IAstroidChecker


class GenericForeignKeyChecker(BaseChecker):
__implements__ = (IAstroidChecker,)

name = "generic-foreign-key-checker"

msgs = {
Expand All @@ -17,7 +14,7 @@ class GenericForeignKeyChecker(BaseChecker):
)
}

@utils.check_messages("avoid-generic-foreign-key")
@utils.only_required_for_messages("avoid-generic-foreign-key")
def visit_call(self, node):
if (
isinstance(node.func, astroid.Name)
Expand Down
8 changes: 3 additions & 5 deletions kiwi_lint/list_comprehension.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Copyright (c) 2018 Alexander Todorov <[email protected]>
# Copyright (c) 2018,2023 Alexander Todorov <[email protected]>

# Licensed under the GPL 2.0: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html

from pylint import checkers, interfaces
from pylint import checkers
from pylint.checkers import utils


class ListComprehensionChecker(checkers.BaseChecker):
__implements__ = (interfaces.IAstroidChecker,)

name = "list-comprehension-checker"

msgs = {
Expand All @@ -19,6 +17,6 @@ class ListComprehensionChecker(checkers.BaseChecker):
)
}

@utils.check_messages("avoid-list-comprehension")
@utils.only_required_for_messages("avoid-list-comprehension")
def visit_listcomp(self, node):
self.add_message("avoid-list-comprehension", node=node)
8 changes: 2 additions & 6 deletions kiwi_lint/missing_permissions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright (c) 2019-2021 Alexander Todorov <[email protected]>
# Copyright (c) 2019-2021,2023 Alexander Todorov <[email protected]>

# Licensed under the GPL 2.0: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html

import astroid
from pylint import checkers, interfaces
from pylint import checkers

from .utils import is_api_function

Expand All @@ -22,8 +22,6 @@ class MissingPermissionsChecker(checkers.BaseChecker):
]
inside_views_module = False

__implements__ = (interfaces.IAstroidChecker,)

name = "mising-permissions-checker"

msgs = {
Expand Down Expand Up @@ -96,8 +94,6 @@ class MissingAPIPermissionsChecker(checkers.BaseChecker):
Will inspect API functions for the presence of permissions decorator!
"""

__implements__ = (interfaces.IAstroidChecker,)

name = "mising-api-permissions-checker"

msgs = {
Expand Down
10 changes: 4 additions & 6 deletions kiwi_lint/nested_definition.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Copyright (c) 2019 Alexander Todorov <[email protected]>
# Copyright (c) 2019,2023 Alexander Todorov <[email protected]>

# Licensed under the GPL 2.0: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html

import astroid
from pylint import checkers, interfaces
from pylint import checkers
from pylint.checkers import utils


class NestedDefinitionChecker(checkers.BaseChecker):
__implements__ = (interfaces.IAstroidChecker,)

name = "nested-definition-checker"

msgs = {
Expand All @@ -25,12 +23,12 @@ class NestedDefinitionChecker(checkers.BaseChecker):
),
}

@utils.check_messages("nested-function-found")
@utils.only_required_for_messages("nested-function-found")
def visit_functiondef(self, node):
if not isinstance(node.parent, (astroid.Module, astroid.ClassDef)):
self.add_message("nested-function-found", node=node)

@utils.check_messages("nested-class-found")
@utils.only_required_for_messages("nested-class-found")
def visit_classdef(self, node):
if not isinstance(node.parent, astroid.Module) and node.name not in [
"Meta",
Expand Down
8 changes: 3 additions & 5 deletions kiwi_lint/objects_update.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Copyright (c) 2018 Alexander Todorov <[email protected]>
# Copyright (c) 2018,2023 Alexander Todorov <[email protected]>

# Licensed under the GPL 2.0: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html

from pylint import checkers, interfaces
from pylint import checkers
from pylint.checkers import utils


class ObjectsUpdateChecker(checkers.BaseChecker):
__implements__ = (interfaces.IAstroidChecker,)

name = "objects-update-checker"

msgs = {
Expand All @@ -19,7 +17,7 @@ class ObjectsUpdateChecker(checkers.BaseChecker):
)
}

@utils.check_messages("objects-update-used")
@utils.only_required_for_messages("objects-update-used")
def visit_attribute(self, node):
"""
Note: this checker will produce false-positives on
Expand Down
Loading
Loading