-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
since the ast AnnAssign class can be value-less, avoid resolution fai… #148
Conversation
…lure in this stylistically questionable but syntactically valid edge case
Codecov Report
@@ Coverage Diff @@
## master #148 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 18 18
Lines 4170 4171 +1
=========================================
+ Hits 4170 4171 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you! This fixes a bug, so please do add an entry in the Fixed
section of the changelog.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Done! Thanks again for your invaluable contribution to the community with this package. I look forward to continuing using it in the future! |
Thanks so much to everyone in the community (especially @mauvilsa !) for this immensely valuable package!
This PR fixes #147.
What does this PR do?
According to the current cpython abstract grammar definition, the value of an
ast.AnnAssign
class can beNone
(also discussed in PEP 526) whether within methods or in the class body. So though it's usually considered bad practice stylistically, since it's valid syntax, AST-based parameter resolution should handle this edge case I think.I've written a tiny one-line fix for this issue and added an associated test in the parameter-resolver test module.
In case it's relevant, an alternate approach to testing that I validated was to simply add a value-less annotation within the
__init__
method of ClassA but I ultimately decided that isolating the test the way I've done in this PR might make more sense.