Skip to content

Preserve qualified user types that shadow typing names - #323

Closed
ryanduguid wants to merge 5 commits into
pybind:mainfrom
ryanduguid:fix-qualified-typing-names
Closed

ryanduguid wants to merge 5 commits into
pybind:mainfrom
ryanduguid:fix-qualified-typing-names

Conversation

@ryanduguid

@ryanduguid ryanduguid commented Oct 8, 2026 •

Copy link
Copy Markdown

Summary

Qualified user classes named Sequence or List currently become typing.Sequence or list after their module prefix is removed. Record whether each parsed type was originally qualified so recursive normalisation keeps the user class, while retaining substitutions for the three filtered pybind11 map view classes.

Fixes #241. Extend the existing native aliases fixture and regenerate its references for constructors, direct and nested annotations, and foreign module references.

Evidence

With the new native fixture, the baseline generates the first signature; this change generates the second:

-def get_sequence(arg0: typing.Sequence) -> typing.Sequence: ...
+def get_sequence(arg0: Sequence) -> Sequence: ...
  • uv tool run --with tox-uv tox passes all 13 configured environments with exit code 0 after regenerating and reviewing the references, including nested user List under current and legacy producers.
  • uv lock --check, uv sync, uv run pre-commit run --all-files and uv build pass. All five configured Gemmi CLI modes run successfully on Python 3.10 to 3.13.
  • Supplemental checks pass 16 signatures and five metadata/import controls on Python 3.14.8, including unions, callables, runtime annotations and parameterised map views.

The existing diagnostic script has path resolution and exit status bugs, so diagnostics were also checked separately. In all 13 environments, the baseline and candidate produce equal stderr after hexadecimal-token and text-mode newline normalisation against the same native fixture; diagnostic line multiplicities match the references. Reference line order differs on both revisions.

Risk

The change affects types whose original qualified names were shortened before typing-name conversion. The provenance field has a default and is excluded from equality and representation. The existing name-based map-view filter still determines its three substitutions. Dataclass introspection sees the added provenance field.

Unverified

Native Windows/macOS runs, downstream projects and hosted CI remain unverified. Local tox follows its configured environments, including their CMake versions; exact GitHub Actions orchestration was not reproduced.

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.

Incorrect type hints for custom classes named Sequence, Union, etc

1 participant