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

remove Optional from type of __slots__ #2128

Merged
merged 1 commit into from
Jun 11, 2018
Merged

Conversation

JelleZijlstra
Copy link
Member

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.

JelleZijlstra added a commit to JelleZijlstra/mypy that referenced this pull request May 14, 2018
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]]]
Copy link
Contributor

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.

Copy link
Member Author

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.)

Copy link
Contributor

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.

@gvanrossum gvanrossum merged commit f5a74fd into python:master Jun 11, 2018
@gvanrossum
Copy link
Member

OK, stand by for more test failures until I merge the companion PR in mypy, python/mypy#5046.

@JelleZijlstra JelleZijlstra deleted the slots branch June 11, 2018 21:33
@gvanrossum
Copy link
Member

Oh, this also broke because the two copies are now out of sync. Will fix.

gvanrossum pushed a commit to gvanrossum/mypy that referenced this pull request Jun 11, 2018
Needed after python/typeshed#2128; this will fail tests until the
typeshed change is merged.
yedpodtrzitko pushed a commit to yedpodtrzitko/typeshed that referenced this pull request Jan 23, 2019
yedpodtrzitko pushed a commit to yedpodtrzitko/typeshed that referenced this pull request Jan 23, 2019
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

Successfully merging this pull request may close these issues.

3 participants