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

Consider expression before statement when determining binding kind #12346

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

charliermarsh
Copy link
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
17 checks passed
@charliermarsh charliermarsh deleted the charlie/expr-stmt branch July 16, 2024 14:49
Copy link
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
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