[New-bugs-announce] [issue46345] Add an explicit test for `get_type_hints` for a class field with `None` default

Nikita Sobolev report at bugs.python.org
Tue Jan 11 10:12:50 EST 2022


New submission from Nikita Sobolev <mail at sobolevn.me>:

Right now this corner case is not tested:

```python
class Some:
    x: int = None

import typing
assert typing.get_type_hints(Some) == {'x': int}
```

Notice that we don't add implicit `Optional` type to `x`. This is different for function arguments that will have `Optional` added.

I think it is a good idea to add a test for this. Espeically given that we can change function's behavior.

Context:
- https://bugs.python.org/issue46195
- https://github.com/python/cpython/pull/30304

----------
components: Library (Lib)
messages: 410307
nosy: sobolevn
priority: normal
severity: normal
status: open
title: Add an explicit test for `get_type_hints` for a class field with `None` default
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46345>
_______________________________________


More information about the New-bugs-announce mailing list