Closed intgr closed 4 years ago
Sure, making typing_extensions
dependency optional conditional sounds reasonable.
By the way: Does it bother you that Literal['bla', None]
is considered is_optional=False
in TypeInfo
but it's actually equivalent to Optional[Literal['bla']]
, which would have is_optional=True
?
Should I change is_optional_type
as well?
Meh, it doesn't really bother me, as it still does the right thing atm. There's more strange constructs that don't really do the right thing in TypeInfo
(consider Union[None, str, int]
or Union[Literal[..], Literal[..]]
). If it becomes a problem I'd want to refactor that whole thing to be a bit more robust, or probably just vendor it out to an external implementation to handle all the subtleties.
Since the Literal type is not available before Python 3.8, this introduces a new dependency typing_extensions, which backports it.