Skip to content

[ruff-0.9] Stabilise two flake8-builtins rules#15322

Merged
MichaReiser merged 1 commit intoruff-0.9from
alex/flake8-builtins-stabilisations
Jan 8, 2025
Merged

[ruff-0.9] Stabilise two flake8-builtins rules#15322
MichaReiser merged 1 commit intoruff-0.9from
alex/flake8-builtins-stabilisations

Conversation

@AlexWaygood
Copy link
Member

Summary

This PR stabilises two flake8-builtins rules:

  • builtin-module-shadowing (A005)
  • builtin-lambda-argument-shadowing (A006)

There are no open issues or PRs about either rule except for #15293, which I think should probably not block stabilisation as it's a general problem that I think probably applies to many rules currently.

Test Plan

Ecosystem check on this PR

@AlexWaygood AlexWaygood added the rule Implementing or modifying a lint rule label Jan 7, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2025

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+87 -0 violations, +0 -0 fixes in 10 projects; 45 projects unchanged)

Snowflake-Labs/snowcli (+7 -0 violations, +0 -0 fixes)

+ src/snowflake/cli/_plugins/cortex/types.py:1:1: A005 Module `types` is shadowing a Python builtin module
+ src/snowflake/cli/_plugins/notebook/types.py:1:1: A005 Module `types` is shadowing a Python builtin module
+ src/snowflake/cli/api/console/abc.py:1:1: A005 Module `abc` is shadowing a Python builtin module
+ src/snowflake/cli/api/console/enum.py:1:1: A005 Module `enum` is shadowing a Python builtin module
+ src/snowflake/cli/api/errno.py:1:1: A005 Module `errno` is shadowing a Python builtin module
+ src/snowflake/cli/api/output/types.py:1:1: A005 Module `types` is shadowing a Python builtin module
+ src/snowflake/cli/api/utils/types.py:1:1: A005 Module `types` is shadowing a Python builtin module

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

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

+ airflow/api_connexion/types.py:1:1: A005 Module `types` is shadowing a Python builtin module
+ airflow/api_fastapi/common/types.py:1:1: A005 Module `types` is shadowing a Python builtin module
+ airflow/api_fastapi/execution_api/datamodels/token.py:1:1: A005 Module `token` is shadowing a Python builtin module
+ airflow/io/utils/stat.py:1:1: A005 Module `stat` is shadowing a Python builtin module
+ airflow/models/operator.py:1:1: A005 Module `operator` is shadowing a Python builtin module
+ airflow/operators/email.py:1:1: A005 Module `email` is shadowing a Python builtin module
+ airflow/serialization/serializers/datetime.py:1:1: A005 Module `datetime` is shadowing a Python builtin module
+ airflow/utils/email.py:1:1: A005 Module `email` is shadowing a Python builtin module
+ airflow/utils/json.py:1:1: A005 Module `json` is shadowing a Python builtin module
+ airflow/utils/platform.py:1:1: A005 Module `platform` is shadowing a Python builtin module
+ airflow/utils/types.py:1:1: A005 Module `types` is shadowing a Python builtin module
+ airflow/utils/warnings.py:1:1: A005 Module `warnings` is shadowing a Python builtin module
+ providers/src/airflow/providers/cncf/kubernetes/operators/resource.py:1:1: A005 Module `resource` is shadowing a Python builtin module
... 10 additional changes omitted for project

apache/superset (+15 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

+ superset/advanced_data_type/types.py:1:1: A005 Module `types` is shadowing a Python builtin module
+ superset/commands/dashboard/copy.py:1:1: A005 Module `copy` is shadowing a Python builtin module
+ superset/dashboards/permalink/types.py:1:1: A005 Module `types` is shadowing a Python builtin module
+ superset/databases/types.py:1:1: A005 Module `types` is shadowing a Python builtin module
+ superset/distributed_lock/types.py:1:1: A005 Module `types` is shadowing a Python builtin module
+ superset/explore/permalink/types.py:1:1: A005 Module `types` is shadowing a Python builtin module
... 9 additional changes omitted for rule A005
+ superset/migrations/versions/2018-07-22_11-59_bebcf3fed1fe_convert_dashboard_v1_positions.py:228:27: A006 Lambda argument `sum` is shadowing a Python builtin
... 8 additional changes omitted for project

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

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

+ src/bokeh/application/handlers/code.py:1:1: A005 Module `code` is shadowing a Python builtin module
+ src/bokeh/command/subcommands/json.py:1:1: A005 Module `json` is shadowing a Python builtin module
+ src/bokeh/core/property/datetime.py:1:1: A005 Module `datetime` is shadowing a Python builtin module
+ src/bokeh/core/property/enum.py:1:1: A005 Module `enum` is shadowing a Python builtin module
+ src/bokeh/core/property/json.py:1:1: A005 Module `json` is shadowing a Python builtin module
+ src/bokeh/core/property/string.py:1:1: A005 Module `string` is shadowing a Python builtin module
+ src/bokeh/core/property/struct.py:1:1: A005 Module `struct` is shadowing a Python builtin module
+ src/bokeh/core/types.py:1:1: A005 Module `types` is shadowing a Python builtin module
+ src/bokeh/core/validation/warnings.py:1:1: A005 Module `warnings` is shadowing a Python builtin module
+ src/bokeh/document/json.py:1:1: A005 Module `json` is shadowing a Python builtin module
... 5 additional changes omitted for project

latchbio/latch (+8 -0 violations, +0 -0 fixes)

+ src/latch/functions/secrets.py:1:1: A005 Module `secrets` is shadowing a Python builtin module
+ src/latch/registry/types.py:1:1: A005 Module `types` is shadowing a Python builtin module
+ src/latch/registry/upstream_types/types.py:1:1: A005 Module `types` is shadowing a Python builtin module
+ src/latch/types/glob.py:1:1: A005 Module `glob` is shadowing a Python builtin module
+ src/latch/types/json.py:1:1: A005 Module `json` is shadowing a Python builtin module
+ src/latch_cli/exceptions/traceback.py:1:1: A005 Module `traceback` is shadowing a Python builtin module
+ src/latch_cli/services/cp/glob.py:1:1: A005 Module `glob` is shadowing a Python builtin module
+ src/latch_cli/snakemake/config/parser.py:1:1: A005 Module `parser` is shadowing a Python builtin module

milvus-io/pymilvus (+2 -0 violations, +0 -0 fixes)

+ pymilvus/client/types.py:1:1: A005 Module `types` is shadowing a Python builtin module
+ pymilvus/orm/types.py:1:1: A005 Module `types` is shadowing a Python builtin module

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


yandex/ch-backup (+6 -0 violations, +0 -0 fixes)

+ ch_backup/compression/gzip.py:1:1: A005 Module `gzip` is shadowing a Python builtin module
+ ch_backup/logging.py:1:1: A005 Module `logging` is shadowing a Python builtin module
+ ch_backup/profile.py:1:1: A005 Module `profile` is shadowing a Python builtin module
+ ch_backup/storage/async_pipeline/stages/types.py:1:1: A005 Module `types` is shadowing a Python builtin module
+ tests/integration/modules/datetime.py:1:1: A005 Module `datetime` is shadowing a Python builtin module
+ tests/integration/modules/typing.py:1:1: A005 Module `typing` is shadowing a Python builtin module

zulip/zulip (+7 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

+ zerver/actions/typing.py:1:1: A005 Module `typing` is shadowing a Python builtin module
+ zerver/data_import/slack.py:733:16: A006 Lambda argument `id` is shadowing a Python builtin
+ zerver/lib/profile.py:1:1: A005 Module `profile` is shadowing a Python builtin module
+ zerver/lib/queue.py:1:1: A005 Module `queue` is shadowing a Python builtin module
+ zerver/lib/types.py:1:1: A005 Module `types` is shadowing a Python builtin module
+ zerver/lib/url_preview/types.py:1:1: A005 Module `types` is shadowing a Python builtin module
+ zerver/views/typing.py:1:1: A005 Module `typing` is shadowing a Python builtin module
... 1 additional changes omitted for rule A005

pdm-project/pdm (+4 -0 violations, +0 -0 fixes)

+ src/pdm/cli/commands/cache.py:37:47: FA100 Add `from __future__ import annotations` to simplify `typing.Iterable`
+ src/pdm/cli/commands/cache.py:97:20: FA100 Add `from __future__ import annotations` to simplify `typing.Iterable`
+ src/pdm/cli/commands/config.py:102:36: FA100 Add `from __future__ import annotations` to simplify `typing.Mapping`
+ src/pdm/cli/commands/config.py:102:67: FA100 Add `from __future__ import annotations` to simplify `typing.Mapping`

Changes by rule (3 rules affected)

code total + violation - violation + fix - fix
A005 81 81 0 0 0
FA100 4 4 0 0 0
A006 2 2 0 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+2532 -1599 violations, +4 -0 fixes in 30 projects; 25 projects unchanged)

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

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ tests/core/training/test_interactive.py:663:58: RUF025 [*] Unnecessary empty iterable within a deque call
- tests/core/training/test_interactive.py:663:58: RUF037 [*] Unnecessary empty iterable within a deque call

aiven/aiven-client (+409 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ aiven/client/argx.py:104:38: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ aiven/client/argx.py:155:54: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:171:45: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:174:49: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:241:29: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:278:34: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:278:44: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:290:32: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ aiven/client/argx.py:300:29: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:303:34: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
... 399 additional changes omitted for project

PlasmaPy/PlasmaPy (+0 -4 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

- tests/particles/test_decorators.py:437:5: B903 Class could be dataclass or namedtuple
- tests/particles/test_decorators.py:456:5: B903 Class could be dataclass or namedtuple
- tests/particles/test_decorators.py:494:5: B903 Class could be dataclass or namedtuple
- tests/particles/test_decorators_annotations.py:16:1: B903 Class could be dataclass or namedtuple

apache/airflow (+487 -11 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ airflow/api/auth/backend/deny_all.py:34:24: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api_connexion/parameters.py:87:24: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api_connexion/parameters.py:90:52: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api_connexion/parameters.py:90:78: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api_connexion/security.py:114:6: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api_connexion/security.py:161:54: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
... 478 additional changes omitted for rule UP006
+ airflow/utils/log/logging_mixin.py:175:9: PLR6301 Method `writable` could be a function, class method, or static method
- airflow/utils/log/logging_mixin.py:175:9: PLR6301 Method `writable` could be a function, class method, or static method
+ airflow/utils/log/logging_mixin.py:1:1: CPY001 Missing copyright notice at top of file
- airflow/utils/log/logging_mixin.py:1:1: CPY001 Missing copyright notice at top of file
... 488 additional changes omitted for project

apache/superset (+246 -80 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ scripts/check-env.py:37:40: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ superset/advanced_data_type/types.py:58:21: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ superset/advanced_data_type/types.py:59:23: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ superset/async_events/async_query_manager.py:106:22: UP007 Use `X | Y` for type annotations
- superset/async_events/async_query_manager.py:106:22: UP045 Use `X | None` for type annotations
+ superset/async_events/async_query_manager.py:108:29: UP007 Use `X | Y` for type annotations
- superset/async_events/async_query_manager.py:108:29: UP045 Use `X | None` for type annotations
+ superset/async_events/async_query_manager.py:109:38: UP007 Use `X | Y` for type annotations
- superset/async_events/async_query_manager.py:109:38: UP045 Use `X | None` for type annotations
+ superset/async_events/async_query_manager.py:112:34: UP007 Use `X | Y` for type annotations
... 316 additional changes omitted for project

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

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ release/action.py:27:31: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ release/action.py:27:52: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ release/action.py:35:47: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ release/build.py:144:22: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ release/credentials.py:37:22: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ release/credentials.py:40:38: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ release/pipeline.py:24:12: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ release/pipeline.py:34:31: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ release/ui.py:103:33: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ release/ui.py:24:17: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
... 240 additional changes omitted for project

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

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

- ibis/backends/bigquery/__init__.py:847:48: UP045 [*] Use `X | None` for type annotations
- ibis/common/graph.py:171:46: UP045 [*] Use `X | None` for type annotations
- ibis/common/graph.py:203:50: UP045 [*] Use `X | None` for type annotations
- ibis/common/graph.py:275:41: UP045 [*] Use `X | None` for type annotations
- ibis/common/graph.py:310:47: UP045 [*] Use `X | None` for type annotations
- ibis/common/graph.py:359:47: UP045 [*] Use `X | None` for type annotations
... 97 additional changes omitted for rule UP045
+ ibis/common/tests/test_patterns.py:1122:13: UP006 [*] Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/common/tests/test_patterns.py:1125:10: UP006 [*] Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/common/tests/test_patterns.py:731:31: UP006 [*] Use `collections.abc.Callable` instead of `Callable` for type annotation
... 96 additional changes omitted for project

langchain-ai/langchain (+299 -1149 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ libs/core/langchain_core/_api/beta_decorator.py:128:35: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ libs/core/langchain_core/_api/beta_decorator.py:186:35: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ libs/core/langchain_core/_api/beta_decorator.py:201:35: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ libs/core/langchain_core/_api/beta_decorator.py:30:30: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ libs/core/langchain_core/_api/beta_decorator.py:39:6: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ libs/core/langchain_core/_api/deprecation.py:202:35: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
... 294 additional changes omitted for rule UP006
- libs/core/langchain_core/caches.py:149:36: UP045 Use `X | None` for type annotations
- libs/core/langchain_core/caches.py:167:55: UP045 Use `X | None` for type annotations
- libs/core/langchain_core/caches.py:200:62: UP045 Use `X | None` for type annotations
- libs/core/langchain_core/caches.py:52:55: UP045 Use `X | None` for type annotations
- libs/core/langchain_core/caches.py:97:62: UP045 Use `X | None` for type annotations
- libs/core/langchain_core/callbacks/base.py:104:24: UP045 Use `X | None` for type annotations
... 1143 additional changes omitted for rule UP045
- libs/core/tests/unit_tests/tracers/test_langchain.py:103:5: B903 Class could be dataclass or namedtuple
... 1435 additional changes omitted for project

latchbio/latch (+13 -13 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ src/latch/registry/record.py:188:57: UP007 Use `X | Y` for type annotations
- src/latch/registry/record.py:188:57: UP045 Use `X | None` for type annotations
+ src/latch/registry/record.py:190:64: UP007 Use `X | Y` for type annotations
- src/latch/registry/record.py:190:64: UP045 Use `X | None` for type annotations
+ src/latch/registry/record.py:215:53: UP007 Use `X | Y` for type annotations
- src/latch/registry/record.py:215:53: UP045 Use `X | None` for type annotations
+ src/latch/registry/record.py:217:60: UP007 Use `X | Y` for type annotations
- src/latch/registry/record.py:217:60: UP045 Use `X | None` for type annotations
+ src/latch/registry/record.py:250:10: UP007 Use `X | Y` for type annotations
- src/latch/registry/record.py:250:10: UP045 Use `X | None` for type annotations
... 16 additional changes omitted for project

lnbits/lnbits (+47 -208 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ lnbits/app.py:342:46: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ lnbits/app.py:352:47: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
- lnbits/core/models.py:102:15: UP045 Use `X | None` for type annotations
- lnbits/core/models.py:107:20: UP045 Use `X | None` for type annotations
- lnbits/core/models.py:108:15: UP045 Use `X | None` for type annotations
- lnbits/core/models.py:109:15: UP045 Use `X | None` for type annotations
- lnbits/core/models.py:110:12: UP045 Use `X | None` for type annotations
- lnbits/core/models.py:111:19: UP045 Use `X | None` for type annotations
... 203 additional changes omitted for rule UP045
+ lnbits/core/models.py:332:30: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ lnbits/core/models.py:333:31: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
... 245 additional changes omitted for project

... Truncated remaining completed project reports due to GitHub comment length restrictions

Changes by rule (11 rules affected)

code total + violation - violation + fix - fix
UP006 2431 2431 0 0 0
UP045 1552 0 1552 0 0
UP007 92 92 0 0 0
B903 40 0 40 0 0
FA100 4 4 0 0 0
FURB171 4 0 0 4 0
RUF025 3 3 0 0 0
RUF037 3 0 3 0 0
PLR6301 2 1 1 0 0
CPY001 2 1 1 0 0
RUF100 2 0 2 0 0

@AlexWaygood
Copy link
Member Author

The error message could be a bit better here -- I don't know what a "Python builtin module" is (there's one builtins module, but that's all!). "Python standard library module" would probably be better. I'll do a followup PR to update that, though, so it doesn't ruin the ecosystem report on this PR.

@AlexWaygood
Copy link
Member Author

AlexWaygood commented Jan 7, 2025

The A005 and A006 ecosystem hits all look good to me other than that

@AlexWaygood AlexWaygood requested a review from dylwil3 January 7, 2025 19:15
@MichaReiser
Copy link
Member

There are no open issues or PRs about either rule except for #15293, which I think should probably not block stabilisation as it's a general problem that I think probably applies to many rules currently.

We could also consider PRing a fix for A005 (A006 seems unlikely)

@MichaReiser
Copy link
Member

What's up with all the preview changes 😕

@AlexWaygood
Copy link
Member Author

AlexWaygood commented Jan 8, 2025

What's up with all the preview changes 😕

I think it's because the ruff-0.9 branch is out of date with main, which is confusing the ecosystem check :/

@MichaReiser
Copy link
Member

I can do a rebase once we have fewer open PRs.

@MichaReiser MichaReiser mentioned this pull request Jan 8, 2025
2 tasks
@MichaReiser MichaReiser merged commit e4a479b into ruff-0.9 Jan 8, 2025
@MichaReiser MichaReiser deleted the alex/flake8-builtins-stabilisations branch January 8, 2025 08:50
@AlexWaygood
Copy link
Member Author

There are no open issues or PRs about either rule except for #15293, which I think should probably not block stabilisation as it's a general problem that I think probably applies to many rules currently.

We could also consider PRing a fix for A005 (A006 seems unlikely)

See #15350

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.

3 participants