Skip to content

isinstance-second-argument-not-valid-type false positive for union types with None #8424

@ytoku

Description

@ytoku

Bug description

#8206 does not fix the issue #8205 if the union type contains None.

# pylint: disable=missing-docstring,invalid-name
a = 1
isinstance(a, None | int)  # raises W1116

Configuration

No response

Command used

pylint test.py

Pylint output

************* Module test
test.py:3:0: W1116: Second argument of isinstance is not a type (isinstance-second-argument-not-valid-type)

------------------------------------------------------------------
Your code has been rated at 5.00/10 (previous run: 5.00/10, +0.00)

Expected behavior

no warnings

Pylint version

pylint 2.17.0
astroid 2.15.0
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]

OS / Environment

No response

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Positive 🦟A message is emitted but nothing is wrong with the codeGood first issueFriendly and approachable by new contributorstyping

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions