Skip to content

isinstance-second-argument-not-valid-type does not handle Enum.enum #8327

Open
@jeromeag

Description

@jeromeag

Bug description

"""just to test pylint isinstance-second-argument-not-valid-type"""
from enum import Enum

Direction = Enum('Direction', ['LEFT', 'RIGHT', 'BOTH'])

def check_direction(direction):
    """just to test pylint isinstance-second-argument-not-valid-type"""
    if not isinstance(direction, Direction):
        raise TypeError(f'Not a RUKind ("{direction}" is a {type(direction)})')

Command used

poetry run pylint a.py

Pylint output

************* Module a
a.py:8:11: W1116: Second argument of isinstance is not a type (isinstance-second-argument-not-valid-type)

------------------------------------------------------------------
Your code has been rated at 8.00/10 (previous run: 6.00/10, +2.00)

Expected behavior


Your code has been rated at 10.00/10 (previous run: 8.00/10, +2.00)

Pylint version

pylint 2.16.2
astroid 2.14.2
Python 3.9.10 (main, Jan 20 2022, 21:37:52) 
[GCC 11.2.0]

OS / Environment

Cygwin
Poetry (version 1.3.2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Negative 🦋No message is emitted but something is wrong with the codeFalse Positive 🦟A message is emitted but nothing is wrong with the codetyping

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions