Skip to content

Commit

Permalink
Replace deprecated check_messages() decorator with only_required_for_…
Browse files Browse the repository at this point in the history
…messages()
  • Loading branch information
atodorov committed Nov 6, 2023
1 parent 5d79ad9 commit acc19df
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion kiwi_lint/auto_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,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)
2 changes: 1 addition & 1 deletion kiwi_lint/bulk_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,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)
2 changes: 1 addition & 1 deletion kiwi_lint/db_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,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)
2 changes: 1 addition & 1 deletion kiwi_lint/docstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ 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]
Expand Down
2 changes: 1 addition & 1 deletion kiwi_lint/dunder_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,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
6 changes: 3 additions & 3 deletions kiwi_lint/empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ 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)
Expand Down Expand Up @@ -69,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 @@ -93,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
2 changes: 1 addition & 1 deletion kiwi_lint/generic_foreign_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,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
2 changes: 1 addition & 1 deletion kiwi_lint/list_comprehension.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,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)
4 changes: 2 additions & 2 deletions kiwi_lint/nested_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,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
2 changes: 1 addition & 1 deletion kiwi_lint/objects_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,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
2 changes: 1 addition & 1 deletion kiwi_lint/one_to_one_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class OneToOneFieldChecker(checkers.BaseChecker):
)
}

@utils.check_messages("one-to-one-field")
@utils.only_required_for_messages("one-to-one-field")
def visit_attribute(self, node):
if node.attrname == "OneToOneField":
self.add_message("one-to-one-field", node=node)
2 changes: 1 addition & 1 deletion kiwi_lint/raw_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RawSQLChecker(checkers.BaseChecker):
)
}

@utils.check_messages("avoid-raw-sql")
@utils.only_required_for_messages("avoid-raw-sql")
def visit_attribute(self, node):
# looking for .extra(select={}) patterns
if node.attrname == "extra" and isinstance(node.parent, astroid.Call):
Expand Down
2 changes: 1 addition & 1 deletion kiwi_lint/similar_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def check_similar_string(self, translation_string):
return key, similarity
return None, None

@utils.check_messages("similar-string")
@utils.only_required_for_messages("similar-string")
def visit_call(self, node):
if not (
isinstance(node.func, astroid.Name)
Expand Down
2 changes: 1 addition & 1 deletion kiwi_lint/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TagsChecker(checkers.BaseChecker):
)
}

@utils.check_messages("tag-objects-get_or_create")
@utils.only_required_for_messages("tag-objects-get_or_create")
def visit_attribute(self, node):
if (
node.attrname == "get_or_create"
Expand Down

0 comments on commit acc19df

Please sign in to comment.