Skip to content

Missing special attributes of class instances inherited from object #943

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 2 commits into from
Feb 20, 2017

Conversation

vlasovskikh
Copy link
Member

This this the follow-up to PR #874 with the non-controversial changes to object.

@matthiaskramm
Copy link
Contributor

Rerunning travis.

@@ -44,6 +45,8 @@ class object:
def __getattribute__(self, name: str) -> Any: ...
def __delattr__(self, name: str) -> None: ...
def __sizeof__(self) -> int: ...
def __reduce__(self) -> Union[str, tuple]: ...
Copy link
Contributor

Choose a reason for hiding this comment

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

You used Union as a return type. In Mypy, this means that code that uses values returned from this method will trigger errors if the usage is valid for a single type only. This is why in general we're avoiding using Unions as return values.

Is this intended, @vlasovskikh?

Copy link
Member Author

Choose a reason for hiding this comment

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

@ambv You're right. object.__reduce__ always returns a tuple unless it's overridden in inheritors. So inheritors are free to specify str or tuple or a specific tuple as the actual return type of the override.

It's up to its inheritors to return either a tuple or a string.
@ambv ambv merged commit 295788b into python:master Feb 20, 2017
@vlasovskikh vlasovskikh deleted the vlan/object-special-attributes branch February 20, 2017 20:04
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