Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Flag all comparisons against builtin types in E721 #8491

Merged
merged 5 commits into from
Nov 6, 2023

Conversation

hauntsaninja
Copy link
Contributor

See #8483. Generalised fix on top of #8485

Based on the output of print("\n".join(k for k, v in builtins.__dict__.items() if isinstance(v, type)))

See astral-sh#8483. Generalised fix on top of astral-sh#8485

Based on the output of `print("\n".join(k for k, v in
builtins.__dict__.items() if isinstance(v, type)))`
Copy link
Contributor

github-actions bot commented Nov 5, 2023

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+222 -0 violations, +0 -0 fixes in 41 projects)

RasaHQ/rasa (+5 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --preview

+ .github/tests/test_validate_gpus.py:26:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ rasa/shared/utils/io.py:66:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ rasa/shared/utils/io.py:68:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ rasa/shared/utils/io.py:93:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ tests/cli/test_utils.py:513:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks

alteryx/featuretools (+1 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --preview

+ featuretools/entityset/entityset.py:402:17: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks

apache/airflow (+4 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --select ALL --preview

+ tests/core/test_configuration.py:1448:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ tests/core/test_configuration.py:1458:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ tests/core/test_configuration.py:1482:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ tests/core/test_configuration.py:1487:20: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks

bokeh/bokeh (+2 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --select ALL --preview

+ examples/server/app/crossfilter/main.py:32:35: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ tests/unit/bokeh/models/test_sources.py:288:20: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks

demisto/content (+15 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --preview

+ Packs/AHA/Integrations/AHA/AHA_test.py:89:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ Packs/Campaign/Scripts/CollectCampaignRecipients/CollectCampaignRecipients_test.py:82:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ Packs/CommonScripts/Scripts/FindSimilarIncidentsV2/find_similar_incidents_test.py:252:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ Packs/CommonScripts/Scripts/FindSimilarIncidentsV2/find_similar_incidents_test.py:280:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ Packs/Mattermost/Scripts/MattermostAskUser/MattermostAskUser_test.py:23:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ Packs/MicrosoftTeams/Integrations/MicrosoftTeams/MicrosoftTeams_test.py:2029:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ Packs/MicrosoftTeams/Integrations/MicrosoftTeams/MicrosoftTeams_test.py:2102:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ Packs/ServiceDeskPlus/Integrations/ServiceDeskPlus/ServiceDeskPlus_test.py:156:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ Packs/TheHiveProject/Integrations/TheHiveProject/TheHiveProject.py:504:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ Packs/TheHiveProject/Integrations/TheHiveProject/TheHiveProject.py:553:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
... 5 additional changes omitted for project

ibis-project/ibis (+3 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --preview

+ ibis/backends/bigquery/tests/system/test_client.py:228:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ ibis/backends/bigquery/tests/system/test_client.py:229:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ ibis/backends/tests/test_client.py:1104:13: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks

ing-bank/probatus (+1 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --preview

+ probatus/stat_tests/distribution_statistics.py:192:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks

pandas-dev/pandas (+191 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --preview

+ pandas/_testing/_warnings.py:172:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/_numba/extensions.py:51:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/algorithms.py:526:13: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/algorithms.py:783:36: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/algorithms.py:933:38: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/array_algos/putmask.py:138:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/array_algos/putmask.py:44:13: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/array_algos/take.py:378:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/arrays/datetimelike.py:451:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/arrays/datetimelike.py:655:40: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/arrays/datetimelike.py:766:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/arrays/datetimes.py:2236:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/arrays/datetimes.py:2423:10: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/arrays/masked.py:483:17: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/arrays/masked.py:939:30: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/arrays/numeric.py:161:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/arrays/numpy_.py:134:35: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/arrays/string_arrow.py:630:32: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/arrays/timedeltas.py:1063:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/arrays/timedeltas.py:672:20: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/computation/expr.py:523:17: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/computation/expr.py:524:20: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/computation/ops.py:242:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/construction.py:602:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/construction.py:642:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/construction.py:775:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/dtypes/astype.py:103:10: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/dtypes/astype.py:131:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/dtypes/astype.py:131:39: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/dtypes/common.py:518:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/dtypes/dtypes.py:1422:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/dtypes/dtypes.py:1794:20: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/dtypes/dtypes.py:450:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/dtypes/missing.py:621:10: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/frame.py:11404:15: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/frame.py:11406:33: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/frame.py:2427:24: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/frame.py:7985:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/frame.py:8012:20: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/generic.py:8245:23: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/generic.py:8247:50: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/generic.py:8271:37: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ pandas/core/groupby/groupby.py:1932:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
... 148 additional changes omitted for project

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
E721 222 222 0 0 0

@hauntsaninja hauntsaninja marked this pull request as draft November 5, 2023 05:43
@charliermarsh
Copy link
Member

Nice, thanks -- this looks reasonable to me.

@hauntsaninja hauntsaninja marked this pull request as ready for review November 5, 2023 19:43
@hauntsaninja hauntsaninja marked this pull request as draft November 5, 2023 19:44
@hauntsaninja hauntsaninja marked this pull request as ready for review November 5, 2023 19:47
@charliermarsh
Copy link
Member

I'm wondering if this should be part of preview. What do you think @zanieb? It doesn't change the intent of the rule, but it will lead to more violations. (And for some of these, there isn't a great workaround right now, since we don't accept type(foo) is object -- which we do accept in preview.)

@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Nov 6, 2023
@hauntsaninja
Copy link
Contributor Author

hauntsaninja commented Nov 6, 2023

I'd be in favour of only landing this change in stable once #7905 is in stable

| "UserWarning"
| "ValueError"
| "Warning"
| "ZeroDivisionError"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's revert this change (but keep the change in the other matches! below).

@charliermarsh
Copy link
Member

@hauntsaninja -- Yeah same. That would be equivalent to reverting this change in the deprecated_* variant.

Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@charliermarsh charliermarsh merged commit 2d5ce45 into astral-sh:main Nov 6, 2023
17 checks passed
@hauntsaninja hauntsaninja deleted the all-builtin-types branch November 6, 2023 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants