Skip to content

Move ellipsis definition to types #11223

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

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1914,9 +1914,13 @@ def __import__(
def __build_class__(__func: Callable[[], _Cell | Any], __name: str, *bases: Any, metaclass: Any = ..., **kwds: Any) -> Any: ...

if sys.version_info >= (3, 10):
# In Python 3.10, EllipsisType is exposed publicly in the types module.
@final
class ellipsis: ...
from types import EllipsisType

# Backwards compatibility hack for folks who relied on the ellipsis type
# existing in typeshed in Python 3.9 and earlier.
ellipsis = EllipsisType
Copy link
Member

Choose a reason for hiding this comment

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

I'd favor removing this at some point, but not sure what the fallout would be.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah I had a better comment that it looks I forgot to commit. Yeah, agreed. One point in time to remove it is when we drop 3.9 support

Copy link
Collaborator

Choose a reason for hiding this comment

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

For reference, I've added this as a to do item to #13782.


Ellipsis: EllipsisType

else:
# Actually the type of Ellipsis is <type 'ellipsis'>, but since it's
Expand All @@ -1925,7 +1929,7 @@ else:
@type_check_only
class ellipsis: ...

Ellipsis: ellipsis
Ellipsis: ellipsis

class BaseException:
args: tuple[Any, ...]
Expand Down
5 changes: 4 additions & 1 deletion stdlib/types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,10 @@ if sys.version_info >= (3, 10):
@final
class NoneType:
def __bool__(self) -> Literal[False]: ...
EllipsisType = ellipsis # noqa: F821 from builtins

@final
class EllipsisType: ...

from builtins import _NotImplementedType

NotImplementedType = _NotImplementedType
Expand Down