-
Notifications
You must be signed in to change notification settings - Fork 53
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
Explicit annotation wins over inferred type #691
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #691 +/- ##
=======================================
Coverage 92.66% 92.66%
=======================================
Files 47 47
Lines 8164 8169 +5
Branches 1954 1955 +1
=======================================
+ Hits 7565 7570 +5
Misses 343 343
Partials 256 256
☔ View full report in Codecov by Sentry. |
The are cases where the inherited annotations from a class in another module won be able to resolve in their new context… I’m not sure what to do with these… |
…doctor into 690-explicit-annotations-wins
I’ll merge this PR next week if there is still no review. |
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.
LGTM, although I wish that functions would move between files less often for ease of review :)
pydoctor/model.py
Outdated
for attrib in self.objectsOfType(Attribute): | ||
# If this attribute has not explicit annotation, | ||
# infer its type from it's ast expression. | ||
if attrib.annotation is None and attrib.value is not None: | ||
# do not override explicit annotation | ||
attrib.annotation = astutils.infer_type(attrib.value) |
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.
This code will not be compatible with the new changes https://github.com/twisted/pydoctor/pull/723/files in the sens that type inference should be done when leaving a module other wise it's parsed_type will not be transformed by _ReferenceTransform
.
Fixes #690
Before

After:
