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

Handle typing.Generic case in MRO #847

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

tristanlatr
Copy link
Contributor

@tristanlatr tristanlatr commented Dec 6, 2024

Fix #846.

This should also speed-up the MRO processing since we now process all classes in topological order and use caching for predecessor MROs, avoiding to re-compute for every subclasses like the current code does.

Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 96.15385% with 2 lines in your changes missing coverage. Please review.

Project coverage is 92.79%. Comparing base (1c6478e) to head (0f32429).

Files with missing lines Patch % Lines
pydoctor/model.py 96.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #847      +/-   ##
==========================================
- Coverage   92.79%   92.79%   -0.01%     
==========================================
  Files          47       47              
  Lines        8468     8491      +23     
  Branches     1550     1555       +5     
==========================================
+ Hits         7858     7879      +21     
- Misses        350      351       +1     
- Partials      260      261       +1     

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

pydoctor/model.py Outdated Show resolved Hide resolved

This comment has been minimized.

2 similar comments

This comment has been minimized.

This comment has been minimized.

@tristanlatr
Copy link
Contributor Author

This is not the most correct implementation. Sorting the MRO is not the way to go. I’ll think about it more but we might have to refactor the whole MRO computing code…

This comment has been minimized.

@tristanlatr tristanlatr marked this pull request as ready for review December 8, 2024 23:14

This comment has been minimized.

1 similar comment

This comment has been minimized.

pydoctor/model.py Outdated Show resolved Hide resolved
pydoctor/model.py Outdated Show resolved Hide resolved
pydoctor/topsort.py Outdated Show resolved Hide resolved

This comment has been minimized.

1 similar comment

This comment has been minimized.

This comment has been minimized.

@tristanlatr tristanlatr mentioned this pull request Dec 9, 2024

This comment has been minimized.

2 similar comments

This comment has been minimized.

This comment has been minimized.

pydoctor/model.py Outdated Show resolved Hide resolved

This comment has been minimized.

pydoctor/model.py Outdated Show resolved Hide resolved

This comment has been minimized.

1 similar comment

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

1 similar comment

This comment has been minimized.

This comment has been minimized.

pydoctor/model.py Outdated Show resolved Hide resolved
pydoctor/model.py Outdated Show resolved Hide resolved
Copy link

Diff from pydoctor_primer, showing the effect of this PR on open source code:

twisted (https://github.com/twisted/twisted)
- /projects/twisted/src/twisted/python/zippath.py:52: Cannot compute linearization of the class inheritance hierarchy
- /projects/twisted/src/twisted/python/zippath.py:261: Cannot compute linearization of the class inheritance hierarchy

assert capsys.readouterr().out == '''mro:31: Cannot compute linearization of the class inheritance hierarchy of 'mro.Duplicates'
mro:9: Cannot compute linearization of the class inheritance hierarchy of 'mro.F1'
mro:10: Cannot compute linearization of the class inheritance hierarchy of 'mro.G1'
'''
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be good to have a test that ensure that a cycle in one of the base classes does not prevent to compute unrelated class’s MROS

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.

Remove duplicated Generic from MRO
1 participant