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

Fix tests on Python 3.11 #1139

Merged
merged 5 commits into from Apr 16, 2022
Merged

Fix tests on Python 3.11 #1139

merged 5 commits into from Apr 16, 2022

Conversation

JelleZijlstra
Copy link
Member

Tests pass for me on a 3.11 build from today now.

- 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.
Copy link
Collaborator

@srittau srittau 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 have one concern that you can ignore if you wish.

Comment on lines +2440 to +2443
if TYPING_3_11_0:
self.assertEqual(repr(Unpack[Ts]), '*Ts')
else:
self.assertEqual(repr(Unpack[Ts]), 'typing_extensions.Unpack[Ts]')
Copy link
Collaborator

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?

Copy link
Member Author

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.

Copy link
Member Author

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?

Copy link

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()?

Copy link
Member Author

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.

@mrahtz
Copy link

mrahtz commented Apr 16, 2022

(Thanks, Jelle!)

@JelleZijlstra JelleZijlstra merged commit 783c8ca into python:master Apr 16, 2022
@JelleZijlstra JelleZijlstra deleted the 311test branch April 16, 2022 17:58
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.

None yet

3 participants