[issue46195] Annotated and Optional get_type_hints buggy interaction

2022-03-01 Thread Jelle Zijlstra
Jelle Zijlstra added the comment: This is now fixed in 3.11, but we'll leave 3.10 and 3.9 alone. Thanks for your bug report! -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue46195] Annotated and Optional get_type_hints buggy interaction

2022-03-01 Thread Jelle Zijlstra
Jelle Zijlstra added the comment: New changeset 20a1c8ee4bcb1c421b7cca1f3f5d6ad7ce30a9c9 by Nikita Sobolev in branch 'main': bpo-46195: Do not add `Optional` in `get_type_hints` (GH-30304) https://github.com/python/cpython/commit/20a1c8ee4bcb1c421b7cca1f3f5d6ad7ce30a9c9 -- nosy:

[issue46195] Annotated and Optional get_type_hints buggy interaction

2021-12-30 Thread Nikita Sobolev
Change by Nikita Sobolev : -- keywords: +patch pull_requests: +28517 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30304 ___ Python tracker ___

[issue46195] Annotated and Optional get_type_hints buggy interaction

2021-12-30 Thread Guido van Rossum
Guido van Rossum added the comment: Yes, we changed PEP 484 in https://github.com/python/peps/pull/689. So get_type_hints() should follow suit. -- ___ Python tracker ___

[issue46195] Annotated and Optional get_type_hints buggy interaction

2021-12-30 Thread Nikita Sobolev
Nikita Sobolev added the comment: As Guido said, the root cause of this problem is because `None` default automatically adds `Optional` to the resulting type. Source: https://github.com/python/cpython/blob/8d7644fa64213207b8dc6f555cb8a02bfabeced2/Lib/typing.py#L1854-L1856 So, what happens

[issue46195] Annotated and Optional get_type_hints buggy interaction

2021-12-29 Thread Nikita Sobolev
Nikita Sobolev added the comment: And on 3.9 as well. -- versions: +Python 3.9 ___ Python tracker ___ ___ Python-bugs-list mailing

[issue46195] Annotated and Optional get_type_hints buggy interaction

2021-12-29 Thread Nikita Sobolev
Change by Nikita Sobolev : -- versions: +Python 3.10, Python 3.11 -Python 3.8 ___ Python tracker ___ ___ Python-bugs-list mailing

[issue46195] Annotated and Optional get_type_hints buggy interaction

2021-12-29 Thread Nikita Sobolev
Nikita Sobolev 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

[issue46195] Annotated and Optional get_type_hints buggy interaction

2021-12-29 Thread Guido van Rossum
Guido van Rossum added the comment: Could you try with 3.10 and the stdlib typing.Annotated please? There might be changes (in the past a default of None automatically caused an Optional to be added, but we changed our minds.-- --Guido (mobile) --

[issue46195] Annotated and Optional get_type_hints buggy interaction

2021-12-29 Thread Mehdi2277
Change by Mehdi2277 : -- type: -> behavior ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46195] Annotated and Optional get_type_hints buggy interaction

2021-12-29 Thread Mehdi2277
New submission from Mehdi2277 : This is two closely related issues with get_type_hints on an optional annotated member. I'm testing with Annotated/get_type_hints from typing extensions on 3.8 and assuming they're backport equivalent to current behavior. The first issue is get_type_hints has