Browse Source
bpo-45166: fixes `get_type_hints` failure on `Final` (GH-28279)
bpo-45166: fixes `get_type_hints` failure on `Final` (GH-28279)
Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>pull/28564/head
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 10 deletions
-
10Lib/test/ann_module5.py
-
7Lib/test/ann_module6.py
-
18Lib/test/test_typing.py
-
29Lib/typing.py
-
2Misc/NEWS.d/next/Library/2021-09-10-21-35-53.bpo-45166.UHipXF.rst
@ -0,0 +1,10 @@ |
|||
# Used by test_typing to verify that Final wrapped in ForwardRef works. |
|||
|
|||
from __future__ import annotations |
|||
|
|||
from typing import Final |
|||
|
|||
name: Final[str] = "final" |
|||
|
|||
class MyClass: |
|||
value: Final = 3000 |
|||
@ -0,0 +1,7 @@ |
|||
# Tests that top-level ClassVar is not allowed |
|||
|
|||
from __future__ import annotations |
|||
|
|||
from typing import ClassVar |
|||
|
|||
wrong: ClassVar[int] = 1 |
|||
@ -0,0 +1,2 @@ |
|||
:func:`typing.get_type_hints` now works with :data:`~typing.Final` wrapped in |
|||
:class:`~typing.ForwardRef`. |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue