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

Localize cleanup for FunctionDef and ClassDef #10837

Merged
merged 1 commit into from
Apr 8, 2024
Merged

Localize cleanup for FunctionDef and ClassDef #10837

merged 1 commit into from
Apr 8, 2024

Conversation

carljm
Copy link
Contributor

@carljm carljm commented Apr 8, 2024

Summary

Came across this code while digging into the semantic model with @AlexWaygood, and found it confusing because of how it splits push_scope from the paired pop_scope (took me a few minutes to even figure out if/where we were popping the pushed scope). Since this "cleanup" is already totally split by node type, there doesn't seem to be any gain in having it as a separate "step" rather than just incorporating it into the traversal clauses for those node types.

I left the equivalent cleanup step alone for the expression case, because in that case it is actually generic across several different node types, and due to the use of the common visit_generators utility there isn't a clear way to keep the pushes and corresponding pops localized.

Feel free to just reject this if I've missed a good reason for it to stay this way!

Test Plan

Tests and clippy.

@charliermarsh
Copy link
Member

Do you mind adding the "Internal" label to this one? We have our release infrastructure configured such that PRs labeled "Internal" are automatically filtered out from the release notes, so saves us some time later.

@carljm carljm added the internal An internal refactor or improvement label Apr 8, 2024
@carljm
Copy link
Contributor Author

carljm commented Apr 8, 2024

Gah, one of these days I'll actually remember to tag my own PR 🙄

Copy link
Contributor

github-actions bot commented Apr 8, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@carljm carljm merged commit e13e57e into main Apr 8, 2024
17 checks passed
@carljm carljm deleted the cjm/simplify branch April 8, 2024 19:29
@davisagli
Copy link

davisagli commented Apr 9, 2024

Hey there, I'm lurking because I wanted to see what @carljm is up to in his first days at Astral. :) We have a similar scheme for release notes based on labels in a project I work on, and we use https://github.com/agilepathway/label-checker to set a failed check on the PR if it doesn't have one of the required labels.

@carljm
Copy link
Contributor Author

carljm commented Apr 9, 2024

Hi @davisagli !

I just brought up this automation idea the other day :) But then I withdrew it; I think it would make sense for a private project, but for a project with lots of contributors like ruff, where most PR authors don't even have the rights to set labels, I think it's a bad contributor experience (and a bad reviewer experience!) for every PR to by default get the big red X until a maintainer comes along to set a label. I'd rather have the maintainers need to remember to do it.

@T-256
Copy link
Contributor

T-256 commented Apr 11, 2024

(Just my thoughts and possible solutions on mentioned issues at here)

most PR authors don't even have the rights to set labels

Isn't it possible to specify this for label-checker to validate if PR author has label right or not?

get the big red X until a maintainer comes along to set a label.

I think it could be as Skipped task instead of big red X

Glyphack pushed a commit to Glyphack/ruff that referenced this pull request Apr 12, 2024
## Summary

Came across this code while digging into the semantic model with
@AlexWaygood, and found it confusing because of how it splits
`push_scope` from the paired `pop_scope` (took me a few minutes to even
figure out if/where we were popping the pushed scope). Since this
"cleanup" is already totally split by node type, there doesn't seem to
be any gain in having it as a separate "step" rather than just
incorporating it into the traversal clauses for those node types.

I left the equivalent cleanup step alone for the expression case,
because in that case it is actually generic across several different
node types, and due to the use of the common `visit_generators` utility
there isn't a clear way to keep the pushes and corresponding pops
localized.

Feel free to just reject this if I've missed a good reason for it to
stay this way!

## Test Plan

Tests and clippy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal An internal refactor or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants