Skip to content

Comments

[red-knot] Avoid false-positive diagnostics on * import statements#16899

Merged
AlexWaygood merged 1 commit intomainfrom
alex/star-import-no-error
Mar 21, 2025
Merged

[red-knot] Avoid false-positive diagnostics on * import statements#16899
AlexWaygood merged 1 commit intomainfrom
alex/star-import-no-error

Conversation

@AlexWaygood
Copy link
Member

Summary

This PR removes false-positive diagnostics for * imports. Currently we always emit a diagnostic for these statements unless the module we're importing from has a symbol named "*" in its symbol table for the global scope. (And if we were doing everything correctly, no module ever would have a symbol named "*" in its global scope!)

The fix here is sort-of hacky and won't be what we'll want to do long-term. However, I think it's useful to do this as a first step since:

  • It significantly reduces false positives when running on code that uses * imports
  • It "resets" the tests to a cleaner state with many fewer TODOs, making it easier to see what the hard work is that's still to be done.

Test Plan

cargo test -p red_knot_python_semantic

@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Mar 21, 2025
@github-actions
Copy link
Contributor

mypy_primer results

No ecosystem changes detected ✅

@AlexWaygood AlexWaygood merged commit d21d639 into main Mar 21, 2025
23 checks passed
@AlexWaygood AlexWaygood deleted the alex/star-import-no-error branch March 21, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant