-
Notifications
You must be signed in to change notification settings - Fork 261
Fix tests on Python 3.11 #1139
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix tests on Python 3.11 #1139
Conversation
- Defer to the PEP 646 implementation in typing.py on 3.11 - Adjust some tests accordingly. Noted a bug in python/cpython#32341 (comment) - typing._type_check() is more lenient in 3.11 and no longer rejects ints - The representation of the empty tuple type changed Tests pass for me on a 3.11 build from today now.
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 have one concern that you can ignore if you wish.
if TYPING_3_11_0: | ||
self.assertEqual(repr(Unpack[Ts]), '*Ts') | ||
else: | ||
self.assertEqual(repr(Unpack[Ts]), 'typing_extensions.Unpack[Ts]') |
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.
(Which I forgot to save.)
Wouldn't it make more sense to make the typing_extensions version match the one from Python 3.11?
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.
Yes, I was thinking about that too. On the other hand, *Ts
is a syntax error before 3.11, so it may not be very helpful as repr()
output.
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.
@mrahtz what do you think? Should we use *Ts
in the repr() for Unpack even before 3.11?
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 I agree it should be Unpack[Ts]
before 3.11 - isn't the repr()
suppose to be as close as possible to something you can directly eval()
?
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, then let's stick with the current behavior.
(Thanks, Jelle!) |
gh-87390: Add tests demonstrating current type variable substitution behaviour cpython#32341 (comment)
Tests pass for me on a 3.11 build from today now.