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

add new rule #4

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

iri6e4k0
Copy link

@iri6e4k0 iri6e4k0 commented Sep 4, 2024

Added a new optional rule to the linter, the presence of which is subsequently asserted in contexts marked by the @vedro.context decorator. It is disabled by default.

flake8_vedro/rules/VDR313.md Outdated Show resolved Hide resolved
flake8_vedro/visitors/context_assert_visitor.py Outdated Show resolved Hide resolved
tests/test_assert_in_context.py Show resolved Hide resolved
tests/test_assert_in_context.py Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
flake8_vedro/visitors/context_assert_visitor.py Outdated Show resolved Hide resolved
Comment on lines 18 to 23
for line in context.context_node.body:
if isinstance(line, ast.Assert):
has_assert = True
break

has_assert = self._has_assert_in_block(context.context_node.body)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have a loop for every line in context.context_node.body, for each line there's a call of method _has_assert_in_block for the whole context.context_node.body

are you sure that it's a good solution?


return errors

def _has_assert_in_block(self, block: List[ast.stmt]):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing typing for return value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants