-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request / Question] Minimum length List / Sequence #8501
Comments
This isn't supported by the current type system, and I don't think there are any currently planned features that would allow it. |
I am keeping this open for now because theoretically we can think about overloading |
Yeah no worries, probably can pass around some opaque lists or just runtime
check it in the meantime
…On Fri, 6 Mar 2020 at 19:42, Ivan Levkivskyi ***@***.***> wrote:
I am keeping this open for now because theoretically we can think about
overloading __getitem__() on literal values. But this is very low
priority, so don't be surprised if it will be ultimately closed.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#8501?email_source=notifications&email_token=ABFQDYQEXVMUGETOYRMXOCTRGFGZ3A5CNFSM4LC55CCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOCSUFA#issuecomment-595929620>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABFQDYQJSA7FY7UMC447EOLRGFGZ3ANCNFSM4LC55CCA>
.
|
Similar idea to #8441 |
This would require a new type system feature, so should be discussed at https://github.com/python/typing, possibly at python/typing#786 |
Hi I was wondering if it's possible to create a List/Sequence type with a minimum length
I work with TypeScript a lot too and here's an example TS example: https://stackoverflow.com/questions/49910889/typescript-array-with-minimum-length
(this uses some of the oddities of JavaScript to achieve this I guess)
So I'd like to have an
my_list = AtLeastOneList[str]
which will fail the type check onmy_list[0]
Just wondering if it's possible!
The text was updated successfully, but these errors were encountered: