-
-
Notifications
You must be signed in to change notification settings - Fork 133
Drop support for Python 3.7 #267
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
Conversation
| @skipUnless(TYPING_3_8_0, "NamedTuple had a bad signature on <=3.7") | ||
| def test_signature_is_same_as_typing_NamedTuple(self): | ||
| self.assertEqual(inspect.signature(NamedTuple), inspect.signature(typing.NamedTuple)) |
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 deleted this test, as it no longer makes sense for us to have the same signature as typing.NamedTuple on <3.13, following #240
| return attrs | ||
|
|
||
|
|
||
| def _maybe_adjust_parameters(cls): |
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.
This function used to be used for our implementation of TypedDict and Protocol, but it is now only used for our implementation of Protocol on Python <3.8
|
|
||
| @_ensure_subclassable(lambda bases: (_TypedDict,)) | ||
| def TypedDict(__typename, __fields=_marker, *, total=True, **kwargs): | ||
| def TypedDict(typename, fields=_marker, /, *, total=True, **kwargs): |
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.
Strictly speaking, switching to using PEP-570 syntax here (and elsewhere) is a backwards-incompatible change. Not sure how we feel about that.
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 fine with it.
|
|
||
|
|
||
| if hasattr(typing, "Required"): | ||
| if hasattr(typing, "Required"): # 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.
These kinds of comments are very useful when doing this kind of PR, so I added them in various places that didn't have them
| # On 3.8+, alter the signature so that it matches typing.NamedTuple. | ||
| # The signature of typing.NamedTuple on >=3.8 is invalid syntax in Python 3.7, | ||
| # so just leave the signature as it is on 3.7. | ||
| if sys.version_info >= (3, 8): | ||
| _new_signature = '(typename, fields=None, /, **kwargs)' | ||
| if isinstance(NamedTuple, _types.FunctionType): | ||
| NamedTuple.__text_signature__ = _new_signature | ||
| else: | ||
| NamedTuple.__call__.__text_signature__ = _new_signature | ||
|
|
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.
As mentioned above, monkey-patching the signature so that it appears to be the same as typing.NamedTuple on all versions no longer makes sense following #240
| return NotImplemented | ||
| return True | ||
|
|
||
| if sys.version_info >= (3, 8): |
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.
It makes me so happy to drop the 3.7 branch here :)
JelleZijlstra
left a comment
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!
|
|
||
| @_ensure_subclassable(lambda bases: (_TypedDict,)) | ||
| def TypedDict(__typename, __fields=_marker, *, total=True, **kwargs): | ||
| def TypedDict(typename, fields=_marker, /, *, total=True, **kwargs): |
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 fine with it.
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
No description provided.