Skip to content

remove Optional from type of __slots__ #2128

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
Jun 11, 2018
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
2 changes: 1 addition & 1 deletion stdlib/2/__builtin__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Member

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
Member

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.

__module__ = ... # type: str

def __init__(self) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion stdlib/3/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class object:
__doc__ = ... # type: Optional[str]
__class__ = ... # type: type
__dict__ = ... # type: Dict[str, Any]
__slots__ = ... # type: Optional[Union[str, Iterable[str]]]
__slots__ = ... # type: Union[str, Iterable[str]]
__module__ = ... # type: str
if sys.version_info >= (3, 6):
__annotations__ = ... # type: Dict[str, Any]
Expand Down