Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

alexprabhat99
Copy link
Contributor

Type of Changes

Type
βœ“ πŸ› Bug fix

Description

Closes #10365

@Pierre-Sassoulas Pierre-Sassoulas added this to the 4.0.0 milestone May 6, 2025
Copy link
Contributor

github-actions bot commented May 6, 2025

πŸ€– 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 ec62635

@Pierre-Sassoulas Pierre-Sassoulas added the Needs decision πŸ”’ Needs a decision before implemention or rejection label May 6, 2025
@jacobtylerwalls
Copy link
Member

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!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Needs decision πŸ”’ Needs a decision before implemention or rejection
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unidiomatic-typecheck not flagged for type(x) is type(y)
3 participants