Skip to content

Checking functions that accept Ellipsis arguments #5796

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

Closed
t-vi opened this issue Oct 17, 2018 · 2 comments
Closed

Checking functions that accept Ellipsis arguments #5796

t-vi opened this issue Oct 17, 2018 · 2 comments

Comments

@t-vi
Copy link

t-vi commented Oct 17, 2018

I have a function (__getitem__) that accepts integers or ellipsis arguments.
I haven't found a way to specify this in a stub (pyi) file so that mypy will like it.

class X:
    def __getitem__(self, idx: Union[int, ???]) -> 'X': ...

but what to write in place of ???.
One solution would be None-style Ellipsis, but that doesn't work currently.
(numpy ndarrays would have the same issue, but I haven't found a stub file for them.)

I would greatly appreciate any hint how this works and if there is a way this works, my feature request would be to add a hint in the documentation, too.

@gvanrossum
Copy link
Member

Duplicate of #4791.

@t-vi
Copy link
Author

t-vi commented Oct 17, 2018

Ah, sorry. Thank you for pointing to #4791.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants