Message400021
It works only with simple types
>>> class X(Annotated[list, 'annotation']): pass
...
But not with type aliases
>>> class X(Annotated[List[int], 'annotation']): pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: _GenericAlias.__init__() takes 3 positional arguments but 4 were given
>>> class X(Annotated[list[int], 'annotation']): pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: GenericAlias expected 2 arguments, got 3
And even if the original type is not subclassable, the error message is not always clear:
>>> class X(Annotated[Union[int, str], 'annotation']): pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: _GenericAlias.__init__() takes 3 positional arguments but 4 were given
>>> class X(Annotated[int | str, 'annotation']): pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: _GenericAlias.__init__() takes 3 positional arguments but 4 were given |
|
Date |
User |
Action |
Args |
2021-08-21 07:41:02 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, gvanrossum, kj |
2021-08-21 07:41:02 | serhiy.storchaka | set | messageid: <1629531662.05.0.587324912826.issue44969@roundup.psfhosted.org> |
2021-08-21 07:41:02 | serhiy.storchaka | link | issue44969 messages |
2021-08-21 07:41:01 | serhiy.storchaka | create | |
|