8000 bpo-46603: improve coverage of `typing._strip_annotations` by sobolevn · Pull Request #31063 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-46603: improve coverage of typing._strip_annotations #31063

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2022
Merged
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3355,6 +3355,15 @@ def barfoo4(x: BA3): ...
{"x": typing.Annotated[int | float, "const"]}
)

def test_get_type_hints_annotated_in_union(self): # bpo-46603
def with_union(x: int | list[Annotated[str, 'meta']]): ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all the other paths covered already? This test doesn't seem to cover the _GenericAlias branch in _strip_annotations.

Copy link
Member Author
@sobolevn sobolevn Feb 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, other branches are reported to be covered by other tests in test_typing somewhere.


self.assertEqual(get_type_hints(with_union), {'x': int | list[str]})
self.assertEqual(
get_type_hints(with_union, include_extras=True),
{'x': int | list[Annotated[str, 'meta']]},
)

def test_get_type_hints_annotated_refs(self):

Const = Annotated[T, "Const"]
Expand Down
0