Skip to content

incorrect scenario of unidiomatic-typecheck #10161

Open
@dgutson

Description

@dgutson

Bug description

I think that pylint should detect the case when type() is used to compare two types, in which case IMHO isisntance() should not be used:

if type(a) == type(b):
    ...

Configuration

Command used

pylint

Pylint output

C0123: Use isinstance() rather than type() for a typecheck. (unidiomatic-typecheck)

Expected behavior

No error triggered.

Pylint version

pylint 3.0.3
astroid 3.0.2
Python 3.12.3 (main, Nov  6 2024, 18:32:19) [GCC 13.2.0]

OS / Environment

No response

Additional dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Positive 🦟A message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions