Skip to content

Conversation

@AlexWaygood
Copy link
Member

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:

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'
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'

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'
```
@AlexWaygood
Copy link
Member Author

AlexWaygood commented Sep 28, 2023

(I don't think this really needs a changelog entry, but I'm happy to add one if folks disagree!)

@JelleZijlstra
Copy link
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.

@JelleZijlstra JelleZijlstra merged commit 5d20e9e into python:main Sep 28, 2023
@AlexWaygood AlexWaygood deleted the patch-2 branch September 28, 2023 13:36
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.

2 participants