pylint icon indicating copy to clipboard operation
pylint copied to clipboard

Flag unidiomatic-typecheck for type(x) is type(y)

Open alexprabhat99 opened this issue 11 months ago • 2 comments

Type of Changes

Type
:bug: Bug fix

Description

Closes #10365

alexprabhat99 avatar May 06 '25 12:05 alexprabhat99

🤖 Effect of this PR on checked open source code: 🤖

Effect on home-assistant: The following messages are now emitted:

  1. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/home-assistant/core/blob/0bf807b96e771f855deeaa5d44008f7bf8eac771/homeassistant/helpers/entity.py#L338

Effect on music21: The following messages are now emitted:

  1. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/cuthbertLab/music21/blob/599c5c4128c09d7cee0be077a794326b82b68839/music21/duration.py#L1771
  2. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/cuthbertLab/music21/blob/599c5c4128c09d7cee0be077a794326b82b68839/music21/metadata/primitives.py#L499
  3. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/cuthbertLab/music21/blob/599c5c4128c09d7cee0be077a794326b82b68839/music21/metadata/primitives.py#L898
  4. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/cuthbertLab/music21/blob/599c5c4128c09d7cee0be077a794326b82b68839/music21/metadata/primitives.py#L915
  5. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/cuthbertLab/music21/blob/599c5c4128c09d7cee0be077a794326b82b68839/music21/metadata/primitives.py#L1011
  6. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/cuthbertLab/music21/blob/599c5c4128c09d7cee0be077a794326b82b68839/music21/metadata/primitives.py#L1197
  7. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/cuthbertLab/music21/blob/599c5c4128c09d7cee0be077a794326b82b68839/music21/tree/spans.py#L91
  8. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/cuthbertLab/music21/blob/599c5c4128c09d7cee0be077a794326b82b68839/music21/common/objects.py#L258

Effect on pytest: The following messages are now emitted:

  1. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/pytest-dev/pytest/blob/89b84cb56295c46e1d8834b599e858bc65c15a5b/src/_pytest/assertion/util.py#L263

Effect on django: The following messages are now emitted:

  1. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/django/django/blob/1fb3f57e81239a75eb8f873b392e11534c041fdc/django/db/migrations/operations/models.py#L683

Effect on pandas: The following messages are now emitted:

  1. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/pandas-dev/pandas/blob/7bb58a82d444fa4d672a484180c567b17bed5da4/pandas/core/generic.py#L9301
  2. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/pandas-dev/pandas/blob/7bb58a82d444fa4d672a484180c567b17bed5da4/pandas/core/arrays/masked.py#L1108
  3. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/pandas-dev/pandas/blob/7bb58a82d444fa4d672a484180c567b17bed5da4/pandas/core/arrays/interval.py#L337
  4. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/pandas-dev/pandas/blob/7bb58a82d444fa4d672a484180c567b17bed5da4/pandas/core/arrays/interval.py#L992
  5. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/pandas-dev/pandas/blob/7bb58a82d444fa4d672a484180c567b17bed5da4/pandas/core/arrays/_mixins.py#L175
  6. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/pandas-dev/pandas/blob/7bb58a82d444fa4d672a484180c567b17bed5da4/pandas/core/arrays/base.py#L1510
  7. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/pandas-dev/pandas/blob/7bb58a82d444fa4d672a484180c567b17bed5da4/pandas/core/arrays/arrow/extension_types.py#L43
  8. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/pandas-dev/pandas/blob/7bb58a82d444fa4d672a484180c567b17bed5da4/pandas/core/arrays/arrow/extension_types.py#L97
  9. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/pandas-dev/pandas/blob/7bb58a82d444fa4d672a484180c567b17bed5da4/pandas/core/indexes/base.py#L5545
  10. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/pandas-dev/pandas/blob/7bb58a82d444fa4d672a484180c567b17bed5da4/pandas/core/internals/concat.py#L465

Effect on sentry: The following messages are now emitted:

  1. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/getsentry/sentry/blob/e6287c10d05a093cec48a4b7dc27420279eb3f37/src/sentry/tagstore/types.py#L26
  2. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/getsentry/sentry/blob/e6287c10d05a093cec48a4b7dc27420279eb3f37/src/sentry/apidocs/spectacular_ports.py#L146

Effect on psycopg: The following messages are now emitted:

  1. unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck. https://github.com/psycopg/psycopg/blob/4ab4c02ef8cde95c5e79703cc47d6676426f6d08/psycopg/psycopg/sql.py#L102

This comment was generated for commit ec62635b42d0b4d689616c60b0866ecd3ff2cfa6

github-actions[bot] avatar May 06 '25 12:05 github-actions[bot]

Cool stuff @alexprabhat99! We're still discussing the merit of the idea, but I'm wondering if you'd be game to try to add some sort of exception for calls inside def __eq__(self, other)? If we can filter those out, we might get a much better analysis from the primer. Ta!

jacobtylerwalls avatar May 06 '25 21:05 jacobtylerwalls

This PR needs take over because because it has been open 8 weeks with no activity.

github-actions[bot] avatar Sep 22 '25 02:09 github-actions[bot]

Feel free to reopen if you return to this.

jacobtylerwalls avatar Sep 30 '25 01:09 jacobtylerwalls