Skip to content

Preserve generic arguments and quote strings in conversion type names - #498

Merged
james-d-mitchell merged 3 commits into
mainfrom
codex/fix-450-generic-type-names
Sep 12, 2026
Merged

james-d-mitchell merged 3 commits into
mainfrom
codex/fix-450-generic-type-names

Conversation

@james-d-mitchell

Copy link
Copy Markdown
Member

to() error messages lose generic type arguments, making list[int] and list[str] both appear as list. Use typing.get_origin to preserve these arguments, and wrap string options in double quotes so return types appear as (KnuthBendix, list[int], "Trie", Order.lenlex).

Add regression coverage for generic types, existing name formatting, and the valid and rejected types shown in conversion errors.

Fixes #450.

Validation: all 77 conversion tests pass; Ruff lint, Ruff formatting, Pylint, and git diff --check pass.

@james-d-mitchell
james-d-mitchell force-pushed the codex/fix-450-generic-type-names branch 2 times, most recently from baa9a28 to 3d45ee9 Compare September 10, 2026 08:10

@Joseph-Edwards Joseph-Edwards left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I like the changes in this PR. One small suggestion: should the tuples with only one element have a trailing comma?

TypeError: expected the first keyword argument to be one of:
    [...]
    * (Congruence, str)
    * (FroidurePin)
                  ^ comma here?
    [...]

@james-d-mitchell
james-d-mitchell force-pushed the codex/fix-450-generic-type-names branch from 3d45ee9 to 04f82fb Compare September 12, 2026 11:56
@james-d-mitchell
james-d-mitchell force-pushed the codex/fix-450-generic-type-names branch from 04f82fb to 85799ce Compare September 12, 2026 11:57
@james-d-mitchell

Copy link
Copy Markdown
Member Author

@Joseph-Edwards done, and I also renamed the local variables and argument in _nice_name to be more accurate, and added type annotations.

@james-d-mitchell
james-d-mitchell enabled auto-merge (rebase) September 12, 2026 11:58
@james-d-mitchell
james-d-mitchell merged commit 883eea9 into main Sep 12, 2026
28 checks passed
@james-d-mitchell
james-d-mitchell deleted the codex/fix-450-generic-type-names branch September 17, 2026 14:35
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.

Improve _nice_name in to.py

3 participants