Skip to content

False positive isinstance-second-argument-not-valid-type when testing typing.Iterable #3507

Closed

Description

Steps to reproduce

from typing import Iterable

print(isinstance([], Iterable))

Similar issues exist for other generic collection types such as Sized, Mapping etc.

Current behavior

Second argument of isinstance is not a type (isinstance-second-argument-not-valid-type)

Expected behavior

No warning is issued.

When collections.abc.Iterable is used instead, there is no warning issued. But the way that class is aliased in the typing module is probably too complex for static analysis to deal with and there doesn't seem to be explicit support yet to work around that.

pylint --version output

$ pylint --version
pylint 2.5.0-dev1
astroid 2.4.0
Python 3.8.2 (default, Mar 05 2020, 18:58:42) [GCC]

The astroid version is a dev snapshot as well, but not reported as such. To be exact, I'm using pylint at 0ccf1bc and astroid at f6a36d91.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions