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

#418: Modify B017 to no longer have a false negative when raises() is imported directly from pytest #424

Merged
merged 6 commits into from
Nov 26, 2023

Conversation

azinneck0485
Copy link
Contributor

Logic for check B017 has been updated to check for cases where with raises() is used when raises is imported using an ast.ImportFrom node (that is, from pytest import raises) rather than an ast.Import node, which the current logic handles.

This has included some updates for check B005 to ensure ast.ImportFrom nodes are added to the "imports" set maintained in the BugBearVisitor class.

Tests have been updated to check that this code pattern is now flagged with B017 and tox tests have passed for Python 3.11 (which is what I have installed).

Fixes #418.

Copy link
Collaborator

@cooperlees cooperlees left a comment

Choose a reason for hiding this comment

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

Many thanks for this PR. Code looks good and tests cover all new functionality. Sorry about being slow.

@cooperlees cooperlees merged commit 393fea1 into PyCQA:main Nov 26, 2023
6 checks passed
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.

B017: False negative when "from" imports used
2 participants