Skip to content

[flake8-builtins] Skip lambda expressions in builtin-argument-shadowing (A002)#14144

Merged
dylwil3 merged 5 commits intoastral-sh:mainfrom
dylwil3:argument-shadow
Nov 7, 2024
Merged

[flake8-builtins] Skip lambda expressions in builtin-argument-shadowing (A002)#14144
dylwil3 merged 5 commits intoastral-sh:mainfrom
dylwil3:argument-shadow

Conversation

@dylwil3
Copy link
Collaborator

@dylwil3 dylwil3 commented Nov 7, 2024

Flake8-builtins provides two checks for arguments (really, parameters) of a function shadowing builtins: A002 checks function definitions, and A006 checks lambda expressions. This PR ensures that A002 is restricted to functions rather than lambda expressions.

Closes #14135 .

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2024

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+276 -278 violations, +0 -0 fixes in 7 projects; 47 projects unchanged)

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

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

- airflow/cli/cli_config.py:82:9: A002 Argument `help` is shadowing a Python builtin
+ airflow/cli/cli_config.py:82:9: A002 Function argument `help` is shadowing a Python builtin
- airflow/cli/cli_config.py:86:9: A002 Argument `type` is shadowing a Python builtin
+ airflow/cli/cli_config.py:86:9: A002 Function argument `type` is shadowing a Python builtin
- airflow/models/pool.py:96:25: A002 Argument `id` is shadowing a Python builtin
+ airflow/models/pool.py:96:25: A002 Function argument `id` is shadowing a Python builtin
- airflow/models/taskinstance.py:229:26: A002 Argument `id` is shadowing a Python builtin
+ airflow/models/taskinstance.py:229:26: A002 Function argument `id` is shadowing a Python builtin
- airflow/traces/tracer.py:38:28: A002 Argument `list` is shadowing a Python builtin
+ airflow/traces/tracer.py:38:28: A002 Function argument `list` is shadowing a Python builtin
- airflow/traces/utils.py:36:53: A002 Argument `type` is shadowing a Python builtin
+ airflow/traces/utils.py:36:53: A002 Function argument `type` is shadowing a Python builtin
- dev/assign_cherry_picked_prs_with_milestone.py:381:27: A002 Argument `type` is shadowing a Python builtin
+ dev/assign_cherry_picked_prs_with_milestone.py:381:27: A002 Function argument `type` is shadowing a Python builtin
... 144 additional changes omitted for project

apache/superset (+12 -13 violations, +0 -0 fixes)

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

- superset/migrations/versions/2018-07-22_11-59_bebcf3fed1fe_convert_dashboard_v1_positions.py:228:27: A002 Argument `sum` is shadowing a Python builtin
- superset/models/helpers.py:1429:9: A002 Argument `filter` is shadowing a Python builtin
+ superset/models/helpers.py:1429:9: A002 Function argument `filter` is shadowing a Python builtin
- superset/utils/core.py:590:15: A002 Argument `type` is shadowing a Python builtin
+ superset/utils/core.py:590:15: A002 Function argument `type` is shadowing a Python builtin
- superset/utils/core.py:609:15: A002 Argument `type` is shadowing a Python builtin
+ superset/utils/core.py:609:15: A002 Function argument `type` is shadowing a Python builtin
- tests/integration_tests/base_tests.py:598:9: A002 Argument `filter` is shadowing a Python builtin
+ tests/integration_tests/base_tests.py:598:9: A002 Function argument `filter` is shadowing a Python builtin
- tests/integration_tests/celery_tests.py:64:21: A002 Argument `id` is shadowing a Python builtin
... 15 additional changes omitted for project

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

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

- src/bokeh/core/property/alias.py:83:46: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/alias.py:83:46: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/alias.py:98:39: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/alias.py:98:39: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/any.py:83:58: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/any.py:83:58: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/bases.py:110:57: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/bases.py:110:57: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/bases.py:139:57: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/bases.py:139:57: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/bases.py:449:93: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/bases.py:449:93: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/bases.py:460:57: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/bases.py:460:57: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/bases.py:516:96: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/bases.py:516:96: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/color.py:124:112: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/color.py:124:112: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/color.py:176:55: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/color.py:176:55: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/constraints.py:60:9: A002 Argument `type` is shadowing a Python builtin
... 213 additional changes omitted for project

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


zulip/zulip (+52 -53 violations, +0 -0 fixes)

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

- analytics/lib/counts.py:418:25: A002 Argument `property` is shadowing a Python builtin
+ analytics/lib/counts.py:418:25: A002 Function argument `property` is shadowing a Python builtin
- analytics/lib/counts.py:432:5: A002 Argument `property` is shadowing a Python builtin
+ analytics/lib/counts.py:432:5: A002 Function argument `property` is shadowing a Python builtin
- analytics/lib/counts.py:475:9: A002 Argument `property` is shadowing a Python builtin
+ analytics/lib/counts.py:475:9: A002 Function argument `property` is shadowing a Python builtin
- analytics/lib/counts.py:523:5: A002 Argument `property` is shadowing a Python builtin
+ analytics/lib/counts.py:523:5: A002 Function argument `property` is shadowing a Python builtin
- analytics/lib/counts.py:57:9: A002 Argument `property` is shadowing a Python builtin
+ analytics/lib/counts.py:57:9: A002 Function argument `property` is shadowing a Python builtin
... 95 additional changes omitted for project

zanieb/huggingface-notebooks (+8 -8 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select A,E703,F704,B015,B018,D100

- course/fr/chapter9/section4.ipynb:cell 5:17:13: A002 Argument `input` is shadowing a Python builtin
+ course/fr/chapter9/section4.ipynb:cell 5:17:13: A002 Function argument `input` is shadowing a Python builtin
- diffusers/exploring_simple optimizations_for_sdxl.ipynb:cell 6:10:25: A002 Argument `bytes` is shadowing a Python builtin
+ diffusers/exploring_simple optimizations_for_sdxl.ipynb:cell 6:10:25: A002 Function argument `bytes` is shadowing a Python builtin
- diffusers/in_painting_with_stable_diffusion_using_diffusers.ipynb:cell 15:1:13: A002 Argument `dict` is shadowing a Python builtin
+ diffusers/in_painting_with_stable_diffusion_using_diffusers.ipynb:cell 15:1:13: A002 Function argument `dict` is shadowing a Python builtin
- diffusers/sd_textual_inversion_training.ipynb:cell 22:12:9: A002 Argument `set` is shadowing a Python builtin
+ diffusers/sd_textual_inversion_training.ipynb:cell 22:12:9: A002 Function argument `set` is shadowing a Python builtin
- diffusers/stable_diffusion_textual_inversion_library_navigator.ipynb:cell 7:6:24: A002 Argument `id` is shadowing a Python builtin
+ diffusers/stable_diffusion_textual_inversion_library_navigator.ipynb:cell 7:6:24: A002 Function argument `id` is shadowing a Python builtin
... 6 additional changes omitted for project

openai/openai-cookbook (+8 -8 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select A,E703,F704,B015,B018,D100

- examples/Custom-LLM-as-a-Judge.ipynb:cell 13:21:25: A002 Argument `input` is shadowing a Python builtin
+ examples/Custom-LLM-as-a-Judge.ipynb:cell 13:21:25: A002 Function argument `input` is shadowing a Python builtin
- examples/Custom-LLM-as-a-Judge.ipynb:cell 15:13:16: A002 Argument `input` is shadowing a Python builtin
+ examples/Custom-LLM-as-a-Judge.ipynb:cell 15:13:16: A002 Function argument `input` is shadowing a Python builtin
- examples/Custom-LLM-as-a-Judge.ipynb:cell 18:2:25: A002 Argument `input` is shadowing a Python builtin
+ examples/Custom-LLM-as-a-Judge.ipynb:cell 18:2:25: A002 Function argument `input` is shadowing a Python builtin
- examples/Custom-LLM-as-a-Judge.ipynb:cell 23:37:22: A002 Argument `input` is shadowing a Python builtin
+ examples/Custom-LLM-as-a-Judge.ipynb:cell 23:37:22: A002 Function argument `input` is shadowing a Python builtin
- examples/Custom-LLM-as-a-Judge.ipynb:cell 24:1:16: A002 Argument `input` is shadowing a Python builtin
+ examples/Custom-LLM-as-a-Judge.ipynb:cell 24:1:16: A002 Function argument `input` is shadowing a Python builtin
... 6 additional changes omitted for project

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
A002 554 276 278 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+276 -278 violations, +0 -0 fixes in 6 projects; 48 projects unchanged)

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

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

- airflow/cli/cli_config.py:82:9: A002 Argument `help` is shadowing a Python builtin
+ airflow/cli/cli_config.py:82:9: A002 Function argument `help` is shadowing a Python builtin
- airflow/cli/cli_config.py:86:9: A002 Argument `type` is shadowing a Python builtin
+ airflow/cli/cli_config.py:86:9: A002 Function argument `type` is shadowing a Python builtin
- airflow/models/pool.py:96:25: A002 Argument `id` is shadowing a Python builtin
+ airflow/models/pool.py:96:25: A002 Function argument `id` is shadowing a Python builtin
- airflow/models/taskinstance.py:229:26: A002 Argument `id` is shadowing a Python builtin
+ airflow/models/taskinstance.py:229:26: A002 Function argument `id` is shadowing a Python builtin
- airflow/traces/tracer.py:38:28: A002 Argument `list` is shadowing a Python builtin
+ airflow/traces/tracer.py:38:28: A002 Function argument `list` is shadowing a Python builtin
- airflow/traces/utils.py:36:53: A002 Argument `type` is shadowing a Python builtin
+ airflow/traces/utils.py:36:53: A002 Function argument `type` is shadowing a Python builtin
- dev/assign_cherry_picked_prs_with_milestone.py:381:27: A002 Argument `type` is shadowing a Python builtin
+ dev/assign_cherry_picked_prs_with_milestone.py:381:27: A002 Function argument `type` is shadowing a Python builtin
... 144 additional changes omitted for project

apache/superset (+12 -13 violations, +0 -0 fixes)

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

- superset/migrations/versions/2018-07-22_11-59_bebcf3fed1fe_convert_dashboard_v1_positions.py:228:27: A002 Argument `sum` is shadowing a Python builtin
- superset/models/helpers.py:1429:9: A002 Argument `filter` is shadowing a Python builtin
+ superset/models/helpers.py:1429:9: A002 Function argument `filter` is shadowing a Python builtin
- superset/utils/core.py:590:15: A002 Argument `type` is shadowing a Python builtin
+ superset/utils/core.py:590:15: A002 Function argument `type` is shadowing a Python builtin
- superset/utils/core.py:609:15: A002 Argument `type` is shadowing a Python builtin
+ superset/utils/core.py:609:15: A002 Function argument `type` is shadowing a Python builtin
- tests/integration_tests/base_tests.py:598:9: A002 Argument `filter` is shadowing a Python builtin
+ tests/integration_tests/base_tests.py:598:9: A002 Function argument `filter` is shadowing a Python builtin
- tests/integration_tests/celery_tests.py:64:21: A002 Argument `id` is shadowing a Python builtin
... 15 additional changes omitted for project

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

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

- src/bokeh/core/property/alias.py:83:46: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/alias.py:83:46: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/alias.py:98:39: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/alias.py:98:39: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/any.py:83:58: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/any.py:83:58: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/bases.py:110:57: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/bases.py:110:57: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/bases.py:139:57: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/bases.py:139:57: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/bases.py:449:93: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/bases.py:449:93: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/bases.py:460:57: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/bases.py:460:57: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/bases.py:516:96: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/bases.py:516:96: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/color.py:124:112: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/color.py:124:112: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/color.py:176:55: A002 Argument `help` is shadowing a Python builtin
+ src/bokeh/core/property/color.py:176:55: A002 Function argument `help` is shadowing a Python builtin
- src/bokeh/core/property/constraints.py:60:9: A002 Argument `type` is shadowing a Python builtin
... 213 additional changes omitted for project

zulip/zulip (+52 -53 violations, +0 -0 fixes)

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

- analytics/lib/counts.py:418:25: A002 Argument `property` is shadowing a Python builtin
+ analytics/lib/counts.py:418:25: A002 Function argument `property` is shadowing a Python builtin
- analytics/lib/counts.py:432:5: A002 Argument `property` is shadowing a Python builtin
+ analytics/lib/counts.py:432:5: A002 Function argument `property` is shadowing a Python builtin
- analytics/lib/counts.py:475:9: A002 Argument `property` is shadowing a Python builtin
+ analytics/lib/counts.py:475:9: A002 Function argument `property` is shadowing a Python builtin
- analytics/lib/counts.py:523:5: A002 Argument `property` is shadowing a Python builtin
+ analytics/lib/counts.py:523:5: A002 Function argument `property` is shadowing a Python builtin
- analytics/lib/counts.py:57:9: A002 Argument `property` is shadowing a Python builtin
+ analytics/lib/counts.py:57:9: A002 Function argument `property` is shadowing a Python builtin
... 95 additional changes omitted for project

zanieb/huggingface-notebooks (+8 -8 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select A,E703,F704,B015,B018,D100

- course/fr/chapter9/section4.ipynb:cell 5:17:13: A002 Argument `input` is shadowing a Python builtin
+ course/fr/chapter9/section4.ipynb:cell 5:17:13: A002 Function argument `input` is shadowing a Python builtin
- diffusers/exploring_simple optimizations_for_sdxl.ipynb:cell 6:10:25: A002 Argument `bytes` is shadowing a Python builtin
+ diffusers/exploring_simple optimizations_for_sdxl.ipynb:cell 6:10:25: A002 Function argument `bytes` is shadowing a Python builtin
- diffusers/in_painting_with_stable_diffusion_using_diffusers.ipynb:cell 15:1:13: A002 Argument `dict` is shadowing a Python builtin
+ diffusers/in_painting_with_stable_diffusion_using_diffusers.ipynb:cell 15:1:13: A002 Function argument `dict` is shadowing a Python builtin
- diffusers/sd_textual_inversion_training.ipynb:cell 22:12:9: A002 Argument `set` is shadowing a Python builtin
+ diffusers/sd_textual_inversion_training.ipynb:cell 22:12:9: A002 Function argument `set` is shadowing a Python builtin
- diffusers/stable_diffusion_textual_inversion_library_navigator.ipynb:cell 7:6:24: A002 Argument `id` is shadowing a Python builtin
+ diffusers/stable_diffusion_textual_inversion_library_navigator.ipynb:cell 7:6:24: A002 Function argument `id` is shadowing a Python builtin
... 6 additional changes omitted for project

openai/openai-cookbook (+8 -8 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select A,E703,F704,B015,B018,D100

- examples/Custom-LLM-as-a-Judge.ipynb:cell 13:21:25: A002 Argument `input` is shadowing a Python builtin
+ examples/Custom-LLM-as-a-Judge.ipynb:cell 13:21:25: A002 Function argument `input` is shadowing a Python builtin
- examples/Custom-LLM-as-a-Judge.ipynb:cell 15:13:16: A002 Argument `input` is shadowing a Python builtin
+ examples/Custom-LLM-as-a-Judge.ipynb:cell 15:13:16: A002 Function argument `input` is shadowing a Python builtin
- examples/Custom-LLM-as-a-Judge.ipynb:cell 18:2:25: A002 Argument `input` is shadowing a Python builtin
+ examples/Custom-LLM-as-a-Judge.ipynb:cell 18:2:25: A002 Function argument `input` is shadowing a Python builtin
- examples/Custom-LLM-as-a-Judge.ipynb:cell 23:37:22: A002 Argument `input` is shadowing a Python builtin
+ examples/Custom-LLM-as-a-Judge.ipynb:cell 23:37:22: A002 Function argument `input` is shadowing a Python builtin
- examples/Custom-LLM-as-a-Judge.ipynb:cell 24:1:16: A002 Argument `input` is shadowing a Python builtin
+ examples/Custom-LLM-as-a-Judge.ipynb:cell 24:1:16: A002 Function argument `input` is shadowing a Python builtin
... 6 additional changes omitted for project

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
A002 554 276 278 0 0

@dhruvmanila dhruvmanila added the bug Something isn't working label Nov 7, 2024
@dhruvmanila
Copy link
Member

Should we update the diagnostic message to be more explicit similar to A006? Like "Function argument ..." instead of just "Argument ..."

@dylwil3 dylwil3 enabled auto-merge (squash) November 7, 2024 05:31
@dylwil3 dylwil3 merged commit cb003eb into astral-sh:main Nov 7, 2024
@dylwil3 dylwil3 deleted the argument-shadow branch November 7, 2024 05:56
@dylwil3 dylwil3 restored the argument-shadow branch November 17, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A006 and A002 both trigger for lambda's

2 participants