Closed sanderr closed 1 year ago
Pydantic seems to have a similar check, potentially relevant discussion at https://github.com/pydantic/pydantic/issues/5821#issuecomment-1558520974
You'll probably want a fix similar to https://github.com/pydantic/pydantic/pull/5826
Yeah. I will make a PR soon.
typing_inspect.is_literal
is broken whentyping-extensions-4.6.0
is installed. The following simple check fails. Installingtyping-extensions-4.5.0
makes it work.While
typing_extensions
made some changes in their latest release I believe it didn't introduce any backwards incompatible changes and I would argue the cause is a bug intyping_inspect
. It seems to count ontyping.Literal
andtyping_extensions.Literal
being the same. It importsLiteral
fromtyping_extensions
(here) and uses that for theis_literal
check (here). As far as I can figure out this assumption is unfounded as it was never documented that the two types would be the same, they just happened to be so for a while.typing-extensions-4.6.0
was released earlier today. According to its changelog it includes a bugfix ontyping_extensions.Literal
. Indeed, while ontyping-extensions-4.5.0
typing.Literal is typing_extensions.Literal
this is no longer the case for the new version. As far as I can tell they did not introduce any backwards incompatible changes.I tested this on Python 3.9.15. The issue does not seem to be present on 3.10.10, there
typing.Literal is typing_extensions.Literal
still holds.EDIT: shifted the text around a bit in an effort to make it more readable