Skip to content

Recognize wildcard-imported Literal annotations#549

Open
ShipItAndPray wants to merge 1 commit into
agronholm:masterfrom
ShipItAndPray:fix-489-wildcard-literal-recognition
Open

Recognize wildcard-imported Literal annotations#549
ShipItAndPray wants to merge 1 commit into
agronholm:masterfrom
ShipItAndPray:fix-489-wildcard-literal-recognition

Conversation

@ShipItAndPray

@ShipItAndPray ShipItAndPray commented Apr 27, 2026

Copy link
Copy Markdown

Summary

  • recognize bare Literal as a typing import when it comes from from typing import * or from typing_extensions import *
  • keep the fix narrow to the existing Literal special-case in the transformer
  • add focused regression coverage for wildcard-imported Literal annotations

Closes #489

Testing

  • uv run pytest tests/test_transformer.py -q -k literal_wildcard_import
  • uv run pytest tests/test_transformer.py -q
  • baseline repro used a one-off script with from typing import * plus @typechecked and failed before this change with NameError: name 'hi' is not defined

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 94.92% (+0.009%) from 94.911% — ShipItAndPray:fix-489-wildcard-literal-recognition into agronholm:master

@agronholm

Copy link
Copy Markdown
Owner

Why is Literal special-cased here?

@agronholm

Copy link
Copy Markdown
Owner

Never mind, I get it now. I had to refresh my memory a bit.

@agronholm

Copy link
Copy Markdown
Owner

This still requires a changelog entry.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

typing.Literal can not be correctly checked against if it was imported via wildcard import

4 participants