Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-41370: Evaluate strings as forward refs in PEP 585 generics#30900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
gvanrossum merged 10 commits intopython:mainfromNiklasRosenstein:issue41370
Mar 7, 2022
Merged
Changes from1 commit
Commits
Show all changes
10 commits
Select commitHold shift + click to select a range
e820e3a
convert strings in PEP 585 generic aliases (`types.GenericAlias`) to …
NiklasRosensteinJan 25, 2022
d7f57c7
add unittest for new get_type_hints() behaviour on PEP 585 generics w…
NiklasRosensteinJan 25, 2022
26ab740
add unit test for `from __future__ import annotations`
NiklasRosensteinJan 27, 2022
a04bd5d
add test for recursive type
NiklasRosensteinJan 27, 2022
3416713
📜🤖 Added by blurb_it.
blurb-it[bot]Jan 27, 2022
30a3564
Double backticks because RST.
NiklasRosensteinJan 27, 2022
13a3505
Update Lib/typing.py
NiklasRosensteinJan 27, 2022
33d286a
Update Misc/NEWS.d/next/Library/2022-01-27-11-54-16.bpo-41370.gYxCPE.rst
NiklasRosensteinJan 27, 2022
6cd96b1
Merge branch 'main' into issue41370
NiklasRosensteinFeb 22, 2022
39c5b06
Replace assertIs with assertEqual in test_get_type_hints_annotated
NiklasRosensteinMar 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
add unit test forfrom __future__ import annotations
  • Loading branch information
@NiklasRosenstein
NiklasRosenstein committedJan 27, 2022
commit26ab74013e8274457724eba1a9e83a98a719176d
31 changes: 23 additions & 8 deletionsLib/test/test_typing.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,6 +30,7 @@
from typing import ParamSpec, Concatenate, ParamSpecArgs, ParamSpecKwargs
from typing import TypeGuard
import abc
import textwrap
import typing
import weakref
import types
Expand DownExpand Up@@ -2009,18 +2010,32 @@ def barfoo2(x: CT): ...
def test_generic_pep585_forward_ref(self):
# See https://bugs.python.org/issue41370

class N:
a: list['N']
class C1:
a: list['C1']
self.assertEqual(
get_type_hints(C1, globals(), locals()),
{'a': list[C1]}
)

class C2:
a: dict['C1', list[List[list['C2']]]]
self.assertEqual(
get_type_hints(N, globals(), locals()),
{'a': list[N]}
get_type_hints(C2, globals(), locals()),
{'a':dict[C1,list[List[list[C2]]]]}
)

class M:
a: dict['N', list[List[list['M']]]]
scope = {}
exec(textwrap.dedent('''
from __future__ import annotations
class C3:
a: List[list["C2"]]
'''), scope)
C3 = scope['C3']

self.assertEqual(C3.__annotations__['a'], "List[list['C2']]")
self.assertEqual(
get_type_hints(M, globals(), locals()),
{'a':dict[N, list[List[list[M]]]]}
get_type_hints(C3, globals(), locals()),
{'a': List[list[C2]]}
)

def test_extended_generic_rules_subclassing(self):
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp