Skip to content

Fix #322 (Union[Literal, ...]) - #325

Merged
lebrice merged 3 commits into
masterfrom
lebrice/issue_322
Jul 27, 2026
Merged

Fix #322 (Union[Literal, ...])#325
lebrice merged 3 commits into
masterfrom
lebrice/issue_322

Conversation

@lebrice

@lebrice lebrice commented Sep 5, 2024

Copy link
Copy Markdown
Owner

Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Comment thread test/test_literal.py Outdated
Comment on lines +137 to +138
# TODO: What about this again?
assert parse(Foo, args="--bar=1.23") == Foo(bar=1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This should fail, right?

@lebrice

lebrice commented Jul 27, 2026

Copy link
Copy Markdown
Owner Author

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved the merge conflicts (commit cd57820). The only conflict was in test/test_literal.py — master had moved Literal to typing_extensions, while the PR branch still imported it from typing. Fixed by using typing_extensions.Literal and keeping Union from typing for the new test.

While resolving the conflicts, I also fixed the underlying issue (#322): added a parse_literal function in field_parsing.py that properly maps string inputs to their corresponding literal values, enabling Union[Literal["a"], int] to correctly parse "a" as a string literal and "123" as an integer.

Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.33%. Comparing base (3b5bc23) to head (3179647).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #325      +/-   ##
==========================================
+ Coverage   86.29%   86.33%   +0.03%     
==========================================
  Files          34       34              
  Lines        4554     4566      +12     
==========================================
+ Hits         3930     3942      +12     
  Misses        624      624              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lebrice
lebrice marked this pull request as ready for review July 27, 2026 21:15
@lebrice
lebrice merged commit 7a706be into master Jul 27, 2026
7 checks passed
@lebrice
lebrice deleted the lebrice/issue_322 branch July 27, 2026 21:15
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.

3 participants