Skip to content

Unexpected error behaviour: Parameterized generics cannot be used with class or instance checks #12155

@JohanSchott

Description

@JohanSchott

mypy reports success for

import numpy as np
x = "a"
assert isinstance(x, np.float64)

but fails for

from numpy import float64
x = "a"
assert isinstance(x, float64)

with the error fails.py:3: error: Parameterized generics cannot be used with class or instance checks

I'm using mypy (0.931) and numpy (1.22.2).

Why do I get different results?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-pep-604PEP 604 (union | operator)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions