Message 409340 - Python tracker

Message409340

Author sobolevn
Recipients gvanrossum, kj, med2277, sobolevn
Date 2021-12-30.00:38:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1640824692.62.0.382788886032.issue46195@roundup.psfhosted.org>
In-reply-to
Content
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! :)
History
Date User Action Args
2021-12-30 00:38:12sobolevnsetrecipients: + sobolevn, gvanrossum, kj, med2277
2021-12-30 00:38:12sobolevnsetmessageid: <1640824692.62.0.382788886032.issue46195@roundup.psfhosted.org>
2021-12-30 00:38:12sobolevnlinkissue46195 messages
2021-12-30 00:38:12sobolevncreate