-
Notifications
You must be signed in to change notification settings - Fork 13
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
Fix the MRO order and correctly add metaclass types #88
Conversation
impl.mro.append(faketi) | ||
faketi.metaclass_type = iface.metaclass_type | ||
# Insert the TypeInfo before the builtins.object that's at the end. | ||
impl.mro.insert(len(impl.mro) - 1, faketi) |
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.
Are you sure builtins.object
is the last item each and every time? Would it make sense to add some kind of assertion on that in the code?
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.
I'm pretty sure since mypy will not let you put a base class of object first:
See: https://mypy-play.net/?mypy=0.981&python=3.11&gist=2ba86753872fd1a1fd4fffad9c4ded9a
I'm happy to add an assert too.
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.
Okay, if you can add the assert, I think we can merge this. Thanks for digging into it!
Assertion added. Thanks! |
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.
Great! 👍
actually, it is not that assertion, disregard... |
This fixes the caching error at #86 by ensuring that the faketi has the same metaclass_type as the TypeInfo that is being faked. I also adjusted the MRO so that builtins.object is correctly ignored by the mypy code. (It expected the MRO to end with builtins.object)
Note: This does not fix the fact that mypy 1.0.0 will show a:
This only ensures that error shows up every time so that it can be
# type: ignore
d if you want.Closes #86