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

Improve ruff_python_semantic::all::extract_all_names() #11335

Merged
merged 3 commits into from
May 8, 2024
Merged

Conversation

AlexWaygood
Copy link
Member

Summary

Following 22639c5, this function now lives in the ruff_python_semantic crate. That means we can simplify the function's signature: where previously it required a closure to be passed in, we can now simply pass in a reference to a SemanticModel instance. As well as simplifying the signature of the function, this also means we can make the function more accurate: it now recognises __all__ = builtins.list(["foo", "bar"]) as a valid __all__ definition, as well as __all__ = list(["foo", "bar"]).

Test Plan

I added a new pyflakes fixture. cargo test / cargo insta review.

@AlexWaygood AlexWaygood added the linter Related to the linter label May 8, 2024
Copy link
Contributor

github-actions bot commented May 8, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

crates/ruff_python_semantic/src/all.rs Outdated Show resolved Hide resolved
@MichaReiser MichaReiser added internal An internal refactor or improvement and removed linter Related to the linter labels May 8, 2024
@AlexWaygood
Copy link
Member Author

MichaReiser added internal and removed linter labels

FWIW this does have a small user-visible impact (__all__ = builtins.list(["foo"]) is now recognised as a valid __all__ assignment, when it previously was not). But I'm also fine with skipping the changelog.

@MichaReiser MichaReiser added linter Related to the linter and removed internal An internal refactor or improvement labels May 8, 2024
@AlexWaygood AlexWaygood merged commit dfe4291 into main May 8, 2024
19 checks passed
@AlexWaygood AlexWaygood deleted the improve-all branch May 8, 2024 16:09
augustelalande pushed a commit to augustelalande/ruff that referenced this pull request May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linter Related to the linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants