Skip to content

Annotation parser should not split on ',' or '|' inside string literals #72

@bbopen

Description

@bbopen

Summary

splitTopLevel in src/tywrap.ts doesn’t track string literal boundaries. Annotations like Literal["a,b"] or Literal["x|y"] are split incorrectly, leading to malformed PythonType parsing and invalid TS types.

Failure mode

  • Literal["a,b"] is split into two parts and mapped to "a" and "b" instead of the single literal "a,b".
  • Literal["x|y"] is split at |, producing a union that isn’t in the source.

Evidence

  • src/tywrap.ts splitTopLevel only tracks bracket/paren depth; it ignores quoted strings.

Proposed fix

  • Teach splitTopLevel to recognize quoted string sections and ignore separators inside them.
  • Add tests for Literal strings containing commas and pipes.

Acceptance criteria

  • Literal annotations with embedded , or | parse correctly.
  • Tests cover Literal["a,b"], Literal["x|y"], and nested cases.

Metadata

Metadata

Assignees

Labels

area:toolingArea: tooling and CLIbugSomething isn't workingpriority:p2Priority P2 (medium)

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions