-
-
Notifications
You must be signed in to change notification settings - Fork 111
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 runtime behaviour of PEP 696 #293
Conversation
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.
Thanks! cc @Gobot1234
What's the status of this one? With basic / experimental support for PEP 696 coming in the next mypy release this is basically necessary to use TypeVar defaults. |
It would be good to get more review (if @Gobot1234 or you could review, I'd appreciate it). There's also a CI failure. |
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 don't have the necessary internal knowledge of how typing.py works anymore really to be able to review this properly
👍🏻 I'll look at it tomorrow. |
Co-authored-by: James Hilton-Balfe <[email protected]>
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.
Left a few comments. Most of them are just some minor style ones.
Overall this looks good to me! Thanks @NCPlayz 👍🏻
--
@JelleZijlstra I left suggestions everywhere I could. If you like feel free to merge them. Would be awesome to get this released soon.
Co-authored-by: Marc Mueller <[email protected]>
Thanks for the reviews! Fixed a minor bug but everything seems to be passing. |
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.
Thanks. We need to be extra careful in the cases where we monkeypatch CPython, so I left some comments there.
I'll look into adding a test to this repo that runs the test_typing suite with the typing_extensions monkeypatches enabled.
I'd like to make sure this still passes tests after we merge #353. |
Ci didn't run |
Ci didn't run |
I may have made CI not run any more somehow, will investigate. |
Oh.. just noticed that some changes to unit tests might have broken in one of the merge commits -- or I misunderstood whether the merge commits were meant to change those? |
What specifically is broken? Feel free to send another PR with any fixes. |
@@ -5712,7 +5712,6 @@ class Y(Generic[T], NamedTuple): | |||
self.assertEqual(a.x, 3) | |||
|
|||
things = "arguments" if sys.version_info >= (3, 10) else "parameters" |
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.
Seems like these lines got re-added -- but maybe they were breaking for 3.8/3.9?
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 think so, yes. I see you commented on this in #293 (comment) before; I don't feel too strongly but I think it's best to match CPython's behavior.
In PEP 696 there are two failure modes specified:
This PR aims to implement the runtime behaviour for this PEP that was missed out in the initial support PR #77.
It also brings support for this to Python 3.11+.
One note I had was that the current error will say
Too few parameters for AllTheDefaults; actual 1, expected 5
.For TypeVarLikes with defaults they aren't actually required, so is it worth computing the minimum required then saying
expected at least 2
for this case?Let me know if you have any suggestions!