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

Explicit annotation wins over inferred type #691

Merged
merged 23 commits into from
Sep 10, 2023

Conversation

tristanlatr
Copy link
Contributor

@tristanlatr tristanlatr commented Apr 6, 2023

Fixes #690

Before
Capture d’écran, le 2023-04-06 à 14 48 51

After:
Capture d’écran, le 2023-04-06 à 14 48 21

@codecov
Copy link

codecov bot commented Apr 6, 2023

Codecov Report

Patch coverage: 98.24% and no project coverage change.

Comparison is base (0eab64f) 92.66% compared to head (3cc2061) 92.66%.

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           
Files Changed Coverage Δ
pydoctor/astutils.py 93.68% <97.36%> (+0.78%) ⬆️
pydoctor/astbuilder.py 96.61% <100.00%> (-0.02%) ⬇️
pydoctor/extensions/attrs.py 97.77% <100.00%> (ø)
pydoctor/model.py 94.63% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tristanlatr
Copy link
Contributor Author

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…

@tristanlatr tristanlatr requested a review from a team April 21, 2023 14:56
@tristanlatr tristanlatr marked this pull request as draft May 3, 2023 15:36
@tristanlatr tristanlatr marked this pull request as ready for review May 30, 2023 11:59
@tristanlatr
Copy link
Contributor Author

I’ll merge this PR next week if there is still no review.

Copy link
Member

@glyph glyph left a 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 :)

Comment on lines 1454 to 1459
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)
Copy link
Contributor Author

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 .

@tristanlatr tristanlatr merged commit f8e80c9 into master Sep 10, 2023
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.

Explicit annotation should win over inferred type
2 participants