-
-
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
Return type of slice-aware __getitem__
#902
Comments
You may want to move this discussion to https://github.com/ambv/typehinting or python-ideas as this problem is not specific to mypy. However, we may be able to come up with a mypy-only workaround that doesn't need changes to Here is a strawman proposal that doesn't require changes to
This is a generalization of Python 2 signature comments ( It's true that |
Added to python/typing#72 but leaving this open to discuss implementation possibilities. Filed python/typing#159 for the |
In python/typing#72 we are reaching consensus that having |
We now allow |
This has been discussed before, but since this involves a language item, it is especially important, and it might be acceptable to special-case a solution.
Since
@overload
is not allowed in non-stubs, it's not clear how slicing should be implemented in user-defined containers.In stubs, you can use:
But in source files the best you can do is:
which will require unacceptable casts at every call site. (incidentally,
slice
should be a generic, not every use will beint
).And currently, it is difficult to mix some parts from a stub file and some not. I am currently investigating whether CRTP works though.
The text was updated successfully, but these errors were encountered: