Nikita Sobolev <[email protected]> added the comment:
I can verify that this happens on `3.10` and `main` branches:
```
from typing import Annotated, Optional, get_type_hints
class Foo:
def __init__(self, x: Annotated[Optional[str], "d"] = None): ...
class Foo2:
x: Annotated[Optional[str], "d"] = None
print(get_type_hints(Foo.__init__, include_extras=False)) # ok
# {'x': typing.Optional[str]}
print(get_type_hints(Foo2, include_extras=False)) # ok
# {'x': typing.Optional[str]}
print(get_type_hints(Foo.__init__, include_extras=True)) # not ok?
# {'x': typing.Optional[typing.Annotated[typing.Optional[str], 'd']]}
print(get_type_hints(Foo2, include_extras=True)) # ok
# {'x': typing.Annotated[typing.Optional[str], 'd']}
```
Notice that 3rd case does not look correct: `{'x':
typing.Optional[typing.Annotated[typing.Optional[str], 'd']]}`
In my opinion it should be `{'x': typing.Annotated[typing.Optional[str], 'd']}`
I will look into it! :)
----------
nosy: +sobolevn
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue46195>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com