Skip to content

Commit 1348502

Browse files
committed
Refactor function verb check and update coverage settings
1 parent 18f63e1 commit 1348502

3 files changed

Lines changed: 5 additions & 14 deletions

File tree

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,6 @@ exclude = [".venv"]
7070
show-source = true
7171

7272
[tool.coverage.report]
73-
exclude_also = ["if typing.TYPE_CHECKING:"]
73+
skip_covered = true
74+
show_missing = true
75+
exclude_also = ["if TYPE_CHECKING:"]

src/community_of_python_flake8_plugin/checks/async_get_prefix.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,10 @@
22
import ast
33
import typing
44

5-
from community_of_python_flake8_plugin.constants import VERB_PREFIXES
65
from community_of_python_flake8_plugin.violation_codes import ViolationCodes
76
from community_of_python_flake8_plugin.violations import Violation
87

98

10-
def check_is_verb_name(identifier: str) -> bool:
11-
return any(identifier == verb or identifier.startswith(f"{verb}_") for verb in VERB_PREFIXES)
12-
13-
149
@typing.final
1510
class AsyncGetPrefixCheck(ast.NodeVisitor):
1611
def __init__(self, syntax_tree: ast.AST) -> None: # noqa: ARG002

src/community_of_python_flake8_plugin/checks/function_verb.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@
99

1010

1111
def check_is_ignored_name(identifier: str) -> bool:
12-
if identifier == "_":
13-
return True
14-
if identifier.isupper():
15-
return True
16-
if identifier in {"value", "values", "pattern"}:
12+
if identifier == "main":
1713
return True
1814
if identifier.startswith("__") and identifier.endswith("__"):
1915
return True
@@ -78,9 +74,7 @@ def validate_function_name(
7874
self, ast_node: ast.FunctionDef | ast.AsyncFunctionDef, parent_class: ast.ClassDef | None
7975
) -> None:
8076
if (
81-
ast_node.name == "main"
82-
or (ast_node.name.startswith("__") and ast_node.name.endswith("__"))
83-
or check_is_ignored_name(ast_node.name)
77+
check_is_ignored_name(ast_node.name)
8478
or (parent_class and self.check_inherits_from_whitelisted_class(parent_class))
8579
or check_is_property(ast_node)
8680
or check_is_pytest_fixture(ast_node)

0 commit comments

Comments
 (0)