-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
remove Optional from type of __slots__ #2128
Conversation
Needed after python/typeshed#2128; this will fail tests until the typeshed change is merged.
@@ -28,7 +28,7 @@ class object: | |||
__doc__ = ... # type: Optional[str] | |||
__class__ = ... # type: type | |||
__dict__ = ... # type: Dict[str, Any] | |||
__slots__ = ... # type: Optional[Union[str, unicode, Iterable[Union[str, unicode]]]] | |||
__slots__ = ... # type: Union[str, unicode, Iterable[Union[str, unicode]]] |
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.
Slots can be None
in Python 2, so this isn't quite accurate.
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.
I don't think so.
$ python2.7
Python 2.7.10 (default, Oct 6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> class A(object):
... __slots__ = None
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Error when calling the metaclass bases
'NoneType' object is not iterable
(That's a new-style class. Old-style classes do allow __slots__ = None
, but that's because they allow anything to be set in __slots__
and ignore the value.)
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.
Ah, you are right. I didn't know old style classes don't use slots.
OK, stand by for more test failures until I merge the companion PR in mypy, python/mypy#5046. |
Oh, this also broke because the two copies are now out of sync. Will fix. |
Needed after python/typeshed#2128; this will fail tests until the typeshed change is merged.
Fixes #1853
This is going to fail mypy_selftest in Travis because it needs a concurrent change to mypy. I'll send out a mypy PR for doing that.