Skip to content
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

update ellipsis type #11564

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2160,7 +2160,7 @@ def visit_complex_expr(self, e: ComplexExpr) -> Type:
def visit_ellipsis(self, e: EllipsisExpr) -> Type:
"""Type check '...'."""
if self.chk.options.python_version[0] >= 3:
return self.named_type('builtins.ellipsis')
return self.named_type('_typeshed.ellipsis')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use _typeshed. types in mypy right now. It would be hard to test.

else:
# '...' is not valid in normal Python 2 code, but it can
# be used in stubs. The parser makes sure that we only
Expand Down
4 changes: 4 additions & 0 deletions mypy/typeshed/stdlib/_typeshed/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,7 @@ else:
@final
class NoneType:
def __bool__(self) -> Literal[False]: ...

# Actually the type of Ellipsis is <type 'ellipsis'>, but since it's
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is just synced from here: https://github.com/python/typeshed/blob/master/stdlib/_typeshed/__init__.pyi

Manually updating it is not a good practice.

# not exposed anywhere under that name, we make it private here.
class ellipsis: ...
5 changes: 1 addition & 4 deletions mypy/typeshed/stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ from _typeshed import (
SupportsNext,
SupportsRDivMod,
SupportsWrite,
ellipsis
)
from ast import AST, mod
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
Expand Down Expand Up @@ -1409,10 +1410,6 @@ def __import__(
level: int = ...,
) -> Any: ...

# Actually the type of Ellipsis is <type 'ellipsis'>, but since it's
# not exposed anywhere under that name, we make it private here.
class ellipsis: ...

Ellipsis: ellipsis

class BaseException(object):
Expand Down