Closed levmckinney closed 1 year ago
Okay I found a mitigation:
from typing_extensions import Literal
It seems like its typing.Literal
specifically that has the issue.
This PR is the reason: https://github.com/python/typing_extensions/pull/148
Oh this is really interesting stuff! Thanks @levmckinney for posting the issue, and thanks @brentyi for finding (what appears to be) the cause of the bug!
Did this issue appear suddenly lately? Is there perhaps something I could be doing differently in simple-parsing?
IIRC I'm using typing.get_args
(or some variant of it) to get the parameters of the Literal
type annotation, and passing those as the choices
argument to parser.add_argument
.
This issue also causes DocTestFailure
in simple_parsing/utils.py
for Python 3.9 and Python 3.8.
>>> is_literal(Literal[True, False])
Expected:
True
Got:
False
Describe the bug
Literals
appear to be broken in python 3.9. Valid inputs are not recognized as valid during parsing. Interestingly, I do not appear to have this issue in python 3.10To Reproduce
Expected behavior A clear and concise description of what you expected to happen.
Actual behavior A clear and concise description of what is happening.
Desktop (please complete the following information):
Additional context I am not encountering this bug in python 3.10 it only appears to be causing my python 3.9 CI to fail.
Complete pip freeze