Think up a way to type list
constructor
#383
Unanswered
KotlinIsland
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
From #377
problem:
While this is typesafe, it should contain the same distinctions as
a
, i.e. it should belist[int] | list[str]
.mypy in real life
sorted
takes anyIterable
and returns alist
of that same type, so it's expected:This is almost achievable by using
Any
as the parameter to the bound:There are two issues with this though,
sorted
takes anIterable
ofSupportsRichComparison
, notobject
, so theAny
will allow any type (e.g.Iterable[None]
). And that this returns the inputIterable
instead of converting it to alist
.Ruminations
in TS generic conditional types are distributes across arays:
24/08/2022 Discovery of 'union math'
It appears that mypy already supports this functionality, although I think by accident (only works on overloads)
https://mypy-play.net/?mypy=latest&python=3.10&gist=d9dc9f0d0a4c3d2af48c4b28f526a705
So I think what we need to do is to add it to normal call analysis.
Beta Was this translation helpful? Give feedback.
All reactions