New submission from Vlad Shcherbina <[email protected]>:
from typing import *
def f(arg: str = None):
pass
print(get_type_hints(f))
# {'arg': typing.Union[str, NoneType]}
# as expected
class T(NamedTuple):
field: str = None
print(get_type_hints(T))
# {'field': <class 'str'>}
# but it should be
# {'field': typing.Union[str, NoneType]}
# for consistency
----------
components: Library (Lib)
messages: 313819
nosy: vlad
priority: normal
severity: normal
status: open
title: typing.NamedTuple does not deduce Optional[] from using None as default
field value
type: behavior
versions: Python 3.6, Python 3.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue33075>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com