Skip to content

gh-132467: Add test case to check whether GenericAlias instance is not class, update docstring of typing._GenericAlias #133504

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add tests against standard generic classes, rename test case
  • Loading branch information
AbduazizZiyodov committed May 6, 2025
commit 817a313a16d407f79396681e73fd4543367a4d74
8 changes: 7 additions & 1 deletion Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5638,7 +5638,8 @@ def foo(x: T):

foo(42)

def test_genericalias_isclass(self):
def test_genericalias_instance_isclass(self):
# test against user-defined generic classes
T = TypeVar('T')

class Node(Generic[T]):
Expand All @@ -5653,6 +5654,11 @@ def __init__(self, label: T,
self.assertFalse(inspect.isclass(Node[int]))
self.assertFalse(inspect.isclass(Node[str]))

# test against standard generic classes
self.assertFalse(inspect.isclass(set[int]))
self.assertFalse(inspect.isclass(list[bytes]))
self.assertFalse(inspect.isclass(dict[str, str]))

def test_implicit_any(self):
T = TypeVar('T')

Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy