Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
Open
Labels
Description
Bug report
Bug description:
Hi
I am not sure if this is a bug, but I use the bug template because I couldn't find a better one to submit questions like this one.
The documentation says, "User-defined generic classes can be instantiated.".
importinspectfromtypingimportTypeVar, GenericT=TypeVar("T") classNode(Generic[T]): x: T# Instance attribute (see below)def__init__(self, label: T|None=None) ->None: self.label=labelx=Node("") # Inferred type is Node[str]y=Node(0) # Inferred type is Node[int]z=Node() # Inferred type is Node[Any]# Also OK:y=Node[int](0) print(inspect.isclass(Node)) # Trueprint(inspect.isclass(Node[int])) # False (shouldn't this be True?)print(inspect.isclass(Node[str])) # False (shouldn't this be True?)In the example above, shouldn't calls such as inspect.isclass(Node[int]) return True, since they can be instantiated and used like normal classes?
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status
No status
Status
Todo