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

Bugfix: Verify the element in item_context.args is of type ast.Name #166

Merged
merged 12 commits into from Apr 1, 2021
Merged

Bugfix: Verify the element in item_context.args is of type ast.Name #166

merged 12 commits into from Apr 1, 2021

Conversation

cricalix
Copy link
Contributor

@cricalix cricalix commented Apr 1, 2021

The sample case that broke the assumptions in the code was doing a module.Error type assertRaises. In this case, item_context.args[0] is now a Call object (without an id attr), not a Name object. So, qualify the conditions even more, and add a test case for the sample provided by @DStape.

Should address #164

cricalix and others added 12 commits March 30, 2021 10:50
```with assertRaises(Exception):``` is basically a "catch 'em all" assert that casts far too broad of a net when it comes to detecting failures in code being tested. Assertions should be testing specific failure cases, not "did Python throw /any/ type of error?", and so the context manager form, or the assertRaisesRegex form are far better to use.
Attempts to ensure we're only looking at Name type objects in the item_context.args, since apparently this code is still matching other objects that don't have an id attr.
@cricalix cricalix changed the title Bugfix: Fix #164 again by adding another conditional Bugfix: Verify the element in item_context.args is of type ast.Name Apr 1, 2021
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.

ast is fun. Ok, some more edge cases covered. Hopefully this gets majority.

@cooperlees cooperlees merged commit 3cab68c into PyCQA:master Apr 1, 2021
@DStape
Copy link

DStape commented Apr 2, 2021

Thank you @cricalix and @cooperlees , this diff (v21.4.3) solves the error on my end.

@cooperlees
Copy link
Collaborator

Thanks, sorry for causing it. We needed to do better testing here.

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.

None yet

3 participants