This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tkomiya
Recipients tkomiya
Date 2020-11-08.04:51:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1604811082.57.0.115992838782.issue42288@roundup.psfhosted.org>
In-reply-to
Content
I noticed `typing.get_type_hints()` returns Optional[Any] as a type hints if the default value of the argument is None:

```
$ python
Python 3.9.0 (default, Oct 24 2020, 15:41:29)
[Clang 11.0.3 (clang-1103.0.32.59)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from typing import Any, get_type_hints
>>> def hello(name: Any = None):
...     pass
...
>>> get_type_hints(hello)
{'name': typing.Optional[typing.Any]}
```

I know typing.get_type_hints() wraps the user's type annotation with Optional when the default value of the argument is None. But it is needless to wrap Any with Optional because Any already contains None. It would be better not to wrap it with Optional when the user's annotation is Any.
History
Date User Action Args
2020-11-08 04:51:22tkomiyasetrecipients: + tkomiya
2020-11-08 04:51:22tkomiyasetmessageid: <1604811082.57.0.115992838782.issue42288@roundup.psfhosted.org>
2020-11-08 04:51:22tkomiyalinkissue42288 messages
2020-11-08 04:51:22tkomiyacreate