Skip to content

Conversation

@AlexWaygood
Copy link
Member

Summary

This PR is stacked on top of #10525 -- review that one first!

This PR changes the logic in ruff_linter/src/renamer.rs to correctly rename references to symbols if those references are string references inside __all__ definitions. In order for the renamer to be able to distinguish between __all__ references (which need to have their quotes stripped before they can be renamed) and other references, a new flag is added to the SemanticModelFlags bitflag, DUNDER_ALL_DEFINITION. This flag is inserted into the semantic model when the model is visiting the r.h.s. of an __all__ definition.

Fixes #10508

Test Plan

Several new test cases have been added for PYI025. These include __all__ definitions with triple-quoted strings, raw strings and implicitly concatenated strings.

@AlexWaygood AlexWaygood added bug Something isn't working fixes Related to suggested fixes for violations linter Related to the linter labels Mar 22, 2024
@AlexWaygood AlexWaygood force-pushed the pyi025-incorrect-fix branch from 343814f to c85be69 Compare March 22, 2024 18:01
@github-actions
Copy link
Contributor

github-actions bot commented Mar 22, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Base automatically changed from dunder-all-ranges to main March 22, 2024 18:38
Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fixes Related to suggested fixes for violations linter Related to the linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Strange autofix for PYI025 if "Set" is included in __all__

3 participants