Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Confusing __class__ for instance of non-generic class that subclasses generic class #129

Closed
@JukkaL

Description

@JukkaL

The following program prints __main__.A[int] even though A is not generic. I'd expect it to print something like <class '__main__.A'>.

from typing import Iterator

class A(Iterator[int]):
    def __next__(self): pass

print(A().__class__)

Also, this does not generate an exception, even though A is not generic:

def f(x: A[int]) -> None: pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions