pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.3k stars 1.13k forks source link

False negative for `isinstance-second-argument-not-valid-type` (parameterized generic) #8213

Open nickdrozd opened 1 year ago

nickdrozd commented 1 year ago

Bug description

Parameterized generics can't be used for isinstance.

isinstance(0, list[int])
TypeError: isinstance() argument 2 cannot be a parameterized generic

But Pylint doesn't warn about this.

Configuration

No response

Command used

pylint

Pylint output

no warning

Expected behavior

Raise isinstance-second-argument-not-valid-type

Pylint version

pylint 2.17.0-dev0
astroid 2.15.0-dev0
Python 3.11.0

OS / Environment

No response

Additional dependencies

No response

ReHoss commented 3 months ago

@nickdrozd Hi, could you provide some references about the fact generics cannot be used with isinstance?

nickdrozd commented 3 months ago
ReHoss commented 3 months ago

@nickdrozd thanks!:)