ilevkivskyi / typing_inspect

Runtime inspection utilities for Python typing module
MIT License
350 stars 35 forks source link

Make `get_origin(Literal[...]) == Literal`. #80

Closed anntzer closed 2 years ago

anntzer commented 3 years ago

See https://github.com/ilevkivskyi/typing_inspect/pull/39#issuecomment-907637313.

ilevkivskyi commented 3 years ago

Hm, it looks like some tests failed. Could you please fix them before I can merge this?

anntzer commented 3 years ago

Looks like(?) the failure now arises because of the confusion between typing.Literal (the backport of typing) and typing_extension.Literal. Not sure what the best approach is here...

ilevkivskyi commented 3 years ago

Hm that looks weird: the error messages are like typing_extensions.Literal != typing_extensions.Literal. As a blind guess maybe you can try something "smarter" like returning tp.__origin__ instead of a plain Literal?

anntzer commented 3 years ago

I tried something along these lines (last commit), but no success...

anntzer commented 2 years ago

Now fixed. There are some other failures, but they are unrelated to this PR (see e.g. #84).

ilevkivskyi commented 2 years ago

It looks like there are two other failures because new pytest doesn't support Python 3.5.0 and 3.5.1. Probably we can just stop testing those (so support will be best effort).

Could you please make a separate PR updating typing_extension requirement and test matrix for Python versions?

ilevkivskyi commented 2 years ago

Or actually you mean the issue is still present even on latest typing_extensions? If yes, we will need to investigate. (But you can still make a PR for not testing Python versions if you still have time for this.)

anntzer commented 2 years ago

The failure of tests with Python 3.5.{0,1} is easy to fix so I did that at #85. There's another test failure revolving around TypedDict with python 3.9.12, for which I don't have a quick fix (but which, I'd argue, should not block this PR as it is also completely unrelated).

ilevkivskyi commented 2 years ago

OK, I will merge this now, and will look at the remaining failure later.