Skip to content

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

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

AlexWaygood merged 3 commits into
mainfrom
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 Ruff linter label May 8, 2024
@github-actions

github-actions Bot commented May 8, 2024 •

Copy link
Copy Markdown
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Comment thread crates/ruff_python_semantic/src/all.rs Outdated
@MichaReiser MichaReiser added internal An internal refactor or improvement (not for changelogs) and removed linter Related to the Ruff 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 Ruff linter and removed internal An internal refactor or improvement (not for changelogs) labels May 8, 2024
Comment thread crates/ruff_python_semantic/src/all.rs
@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 Ruff linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants