Skip to content

Commit

Permalink
fix: resolve linter and test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleh Chyhyryn committed Jun 3, 2024
1 parent 8a4415d commit 0d8c7cc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
5 changes: 3 additions & 2 deletions flake8_type_checking/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,9 @@ def _has_injected_annotation(self, node: Union[AsyncFunctionDef, FunctionDef]) -

def _list_annotations(self, node: Union[AsyncFunctionDef, FunctionDef]) -> Iterator[ast.AST]:
for path in [node.args.args, node.args.kwonlyargs]:
for argument in (item for item in path if hasattr(item, 'annotation') and item.annotation):
yield argument.annotation
for argument in (item for item in path if hasattr(item, 'annotation')):
if argument.annotation:
yield argument.annotation


class FastAPIMixin:
Expand Down
38 changes: 14 additions & 24 deletions tests/test_injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,15 @@ def __init__(self, service: Inject[Service]) -> None:


@pytest.mark.parametrize(
('enabled', 'expected'),
'enabled',
[
(False, {
'2:0 ' + TC002.format(module='injector.Inject'),
'3:0 ' + TC002.format(module='services.Service'),
'4:0 ' + TC002.format(module='other_dependency.OtherDependency'),
}),
(
False,
{
'2:0 ' + TC002.format(module='injector.Inject'),
'3:0 ' + TC002.format(module='services.Service'),
'4:0 ' + TC002.format(module='other_dependency.OtherDependency'),
},
False,
{
'2:0 ' + TC002.format(module='injector.Inject'),
'3:0 ' + TC002.format(module='services.Service'),
'4:0 ' + TC002.format(module='other_dependency.OtherDependency'),
},
),
],
)
Expand All @@ -81,20 +76,15 @@ def __init__(self, service: Inject[Service], other: OtherDependency) -> None:


@pytest.mark.parametrize(
('enabled', 'expected'),
'enabled',
[
(False, {
'2:0 ' + TC002.format(module='injector.Inject'),
'3:0 ' + TC002.format(module='services.Service'),
'4:0 ' + TC002.format(module='other_dependency.OtherDependency'),
}),
(
False,
{
'2:0 ' + TC002.format(module='injector.Inject'),
'3:0 ' + TC002.format(module='services.Service'),
'4:0 ' + TC002.format(module='other_dependency.OtherDependency'),
},
False,
{
'2:0 ' + TC002.format(module='injector.Inject'),
'3:0 ' + TC002.format(module='services.Service'),
'4:0 ' + TC002.format(module='other_dependency.OtherDependency'),
},
),
],
)
Expand Down

0 comments on commit 0d8c7cc

Please sign in to comment.