Skip to content

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

Merged
AlexWaygood merged 3 commits intomainfrom
improve-all
May 8, 2024
Merged

Improve ruff_python_semantic::all::extract_all_names()#11335
AlexWaygood merged 3 commits intomainfrom
improve-all

Conversation

@AlexWaygood
Copy link
Copy Markdown
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
@github-actions
Copy link
Copy Markdown
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.

@MichaReiser MichaReiser added internal An internal refactor or improvement and removed linter Related to the linter labels May 8, 2024
@AlexWaygood
Copy link
Copy Markdown
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 requested a review from MichaReiser May 8, 2024 16:06
@AlexWaygood AlexWaygood merged commit dfe4291 into main May 8, 2024
@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.

2 participants