-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
update ellipsis
type
#11564
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
Conversation
i have no idea what i'm doing lol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please explain your idea behind this PR? Maybe I can help you 🙂
@@ -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 |
There was a problem hiding this comment.
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.
@@ -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') |
There was a problem hiding this comment.
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.
@sobolevn i'm trying to make |
Yes, this is going to be hard 🙂 What I can see here:
|
ellipsis is type_check_only in typeshed these days and the problem will go away on its own on Python 3.10 and newer thanks to types.EllipsisType |
it's only marked as # builtins.pyi
if sys.version_info >= (3, 10):
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
Ellipsis: EllipsisType
else:
# Actually the type of Ellipsis is <type 'ellipsis'>, but since it's
# not exposed anywhere under that name, we make it private here.
@final
@type_check_only
class ellipsis: ...
Ellipsis: ellipsis |
We'll remove it in typeshed next year when 3.9 is goodbye python/typeshed#11223 (comment) |
i'm confused as to why this "backwards compatibility hack" for python 3.9 is in the |
in a year it will look like this:
i've seen codebases where people relied on ellipsis to type ellipsis, a little niche, but gives them a way to spell their type check |
see #11559 (comment)