Skip to content

Consider expression before statement when determining binding kind#12346

Merged
charliermarsh merged 1 commit intomainfrom
charlie/expr-stmt
Jul 16, 2024
Merged

Consider expression before statement when determining binding kind#12346
charliermarsh merged 1 commit intomainfrom
charlie/expr-stmt

Conversation

@charliermarsh
Copy link
Copy Markdown
Member

@charliermarsh charliermarsh commented Jul 16, 2024

Summary

I believe these should always bind more tightly -- e.g., in:

for _ in bar(baz for foo in [1]):
    pass

The inner baz and foo should be considered comprehension variables, not for loop bindings.

We need to revisit this more holistically. In some of these cases, BindingKind should probably be a flag, not an enum, since the values aren't mutually exclusive. Separately, we should probably be more precise in how we set it (e.g., by passing down from the parent rather than sniffing in handle_node_store).

Closes #12339

@charliermarsh charliermarsh added the bug Something isn't working label Jul 16, 2024
@charliermarsh charliermarsh enabled auto-merge (squash) July 16, 2024 14:49
@charliermarsh charliermarsh merged commit d0c5925 into main Jul 16, 2024
@charliermarsh charliermarsh deleted the charlie/expr-stmt branch July 16, 2024 14:49
@github-actions
Copy link
Copy Markdown
Contributor

ruff-ecosystem results

Linter (stable)

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

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

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

- dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py:689:51: PLR1704 Redefining argument with the local name `python`

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PLR1704 1 0 1 0 0

Linter (preview)

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

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

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

- dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py:689:51: PLR1704 Redefining argument with the local name `python`

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PLR1704 1 0 1 0 0

@charliermarsh
Copy link
Copy Markdown
Member Author

Ecosystem change is correct.

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.

PLR1704 triggers for list comprehension variable

1 participant