Skip to content

Commit c7a4bcc

Browse files
committed
Rename exception check method and enhance verb name detection
1 parent 0de1ab2 commit c7a4bcc

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/community_of_python_flake8_plugin/checks/dataclass_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def visit_ClassDef(self, ast_node: ast.ClassDef) -> None:
7676
check_inherits_from_bases(ast_node, FINAL_CLASS_EXCLUDED_BASES)
7777
or is_pydantic_model(ast_node)
7878
or is_model_factory(ast_node)
79-
or self._inherits_from_exception(ast_node)
79+
or self._check_inherits_from_exception(ast_node)
8080
):
8181
self.generic_visit(ast_node)
8282
return
@@ -96,7 +96,7 @@ def visit_ClassDef(self, ast_node: ast.ClassDef) -> None:
9696

9797
self.generic_visit(ast_node)
9898

99-
def _inherits_from_exception(self, ast_node: ast.ClassDef) -> bool:
99+
def _check_inherits_from_exception(self, ast_node: ast.ClassDef) -> bool:
100100
"""Check if class inherits from Exception or its subclasses."""
101101
for one_base in ast_node.bases:
102102
if isinstance(one_base, ast.Name) and ("Error" in one_base.id or "Exception" in one_base.id):

src/community_of_python_flake8_plugin/checks/function_verb.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def check_is_ignored_name(identifier: str) -> bool:
1616

1717
def check_is_verb_name(identifier: str) -> bool:
1818
return any(
19-
identifier == one_verb_name or identifier.startswith((f"{one_verb_name}_", f"_{one_verb_name}"))
19+
identifier in {one_verb_name, f"_{one_verb_name}", f"__{one_verb_name}"}
20+
or identifier.startswith((f"{one_verb_name}_", f"_{one_verb_name}_", f"__{one_verb_name}_"))
2021
for one_verb_name in VERB_PREFIXES
2122
)
2223

src/community_of_python_flake8_plugin/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
"unwind",
123123
"replay",
124124
"synchronize",
125+
"count",
125126
}
126127

127128
SCALAR_ANNOTATIONS: typing.Final = {"int", "str", "float", "bool", "bytes", "complex"}

0 commit comments

Comments
 (0)