Skip to content

Prohibit parameterized generics in isinstance #3037

Closed
@pkch

Description

@pkch

As @ilevkivskyi commented (#3005 (comment)), it would be nice to fail type check on this code:

obj = 1
if isinstance(obj, Iterable[int]):
    1

because it fails in runtime with TypeError.

I can easily see this situation inside checker.py:get_isinstance_type() by verifying that len(type.items()[0].ret_type.args) == 0; but is it the right place to message about type validation problems?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions