Make NewType.__call__ params positional-only#288
Merged
JelleZijlstra merged 3 commits intopython:mainfrom Sep 28, 2023
Merged
Conversation
This is really minor, but it means that the signature of `typing_extensions.NewType.__call__` exactly matches that of `typing.NewType.__call__` on all Python versions we support:
```pycon
Python 3.8.16 (default, Mar 2 2023, 03:18:16) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from typing import NewType
>>> x = NewType("x", int)
>>> x(obj=42)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: new_type() got an unexpected keyword argument 'obj'
```
```pycon
Python 3.10.8 | packaged by conda-forge | (main, Nov 24 2022, 14:07:00) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> x = NewType("x", int)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'NewType' is not defined
>>> from typing import NewType
>>> x = NewType("x", int)
>>> x(obj=42)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: NewType.__call__() got an unexpected keyword argument 'obj'
```
Member
Author
|
(I don't think this really needs a changelog entry, but I'm happy to add one if folks disagree!) |
Member
|
Thanks! We should document this in the changelog as it is a user-visible change, but no need to mention it in the docs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is really minor, but it means that the signature of
typing_extensions.NewType.__call__exactly matches that oftyping.NewType.__call__on all Python versions we support: