Skip to content

Conversation

@11happy
Copy link
Contributor

@11happy 11happy commented Aug 30, 2025

Summary

This PR implements F406 https://docs.astral.sh/ruff/rules/undefined-local-with-nested-import-star-usage/ as a semantic syntax error

Test Plan

I have written inline tests as directed in #17412

@11happy 11happy changed the title F406 [syntax-errors]: import from * only allowed at module scope Aug 30, 2025
@11happy 11happy changed the title [syntax-errors]: import from * only allowed at module scope [syntax-errors]: import from * only allowed at module scope (F406) Aug 30, 2025
@11happy
Copy link
Contributor Author

11happy commented Sep 1, 2025

I have fixed the md file test which was causing CI to fail.

Thank you

@github-actions
Copy link
Contributor

github-actions bot commented Sep 2, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@carljm carljm removed their request for review September 2, 2025 17:46
@dhruvmanila dhruvmanila requested a review from ntBre September 3, 2025 04:31
Signed-off-by: 11happy <soni5happy@gmail.com>
Signed-off-by: 11happy <soni5happy@gmail.com>
Signed-off-by: 11happy <soni5happy@gmail.com>
Signed-off-by: 11happy <soni5happy@gmail.com>
@11happy
Copy link
Contributor Author

11happy commented Sep 4, 2025

have resolved the merge conflict as well.
Thank you

Signed-off-by: 11happy <soni5happy@gmail.com>
Signed-off-by: 11happy <soni5happy@gmail.com>
Signed-off-by: 11happy <soni5happy@gmail.com>
@11happy
Copy link
Contributor Author

11happy commented Sep 7, 2025

Hii @ntBre, would appreciate your feedback on this when you get a chance.
Thank you : )

Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

Thanks, this looks good overall, just a few smaller suggestions. While we're here, can we also update this comment:

// F406
checker.report_diagnostic_if_enabled(
pyflakes::rules::UndefinedLocalWithImportStarUsage {
name: reference.name(checker.source()).to_string(),
},
reference.range(),
);

I was getting confused about this other case of F406 we're not handling, but I finally realized that the comment is just wrong. It should say F405, which is not a syntax error.

Signed-off-by: 11happy <soni5happy@gmail.com>
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

Thank you! This looks great to me. I just had one more test idea for a future edge case.

Signed-off-by: 11happy <soni5happy@gmail.com>
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

Thank you!

@ntBre ntBre added the internal An internal refactor or improvement label Sep 16, 2025
@ntBre ntBre merged commit c3f2187 into astral-sh:main Sep 16, 2025
36 checks passed
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.

3 participants