Skip to content

Consider __doc__ always Optional. Fixes issues surfaced with python/mypy#2380. #641

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
Oct 30, 2016
Merged

Consider __doc__ always Optional. Fixes issues surfaced with python/mypy#2380. #641

merged 2 commits into from
Oct 30, 2016

Conversation

TrueBrain
Copy link
Contributor

python/mypy#2380 showed a discrepancy between object and FunctionType in stdlib2. The first defined __doc__ to be str, the second Optional[str]. As FunctionType depends on object, this is no longer valid.

As suggested by @gvanrossum in python/mypy#2380, all __doc__ should be considered Optional.

@@ -23,7 +23,7 @@ The below is an excerpt from the types for the `datetime` module.
```
MAXYEAR = ... # type: int
MINYEAR = ... # type: int
__doc__ = ... # type: str
__doc__ = ... # type: Optional[str]
Copy link
Member

Choose a reason for hiding this comment

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

Honestly I would remove all the dunder variables from the example, they don't add any clarity (and they're not in that file anyway).

@@ -12,7 +12,7 @@ def abstractmethod(funcobj: Any) -> Any: ...
class ABCMeta(type):
# TODO: FrozenSet
__abstractmethods__ = ... # type: Set[Any]
__doc__ = ... # type: str
__doc__ = ... # type: Optional[str]
Copy link
Member

Choose a reason for hiding this comment

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

No class other than object actually needs to declare __doc__ at all. They just inherit it from object. I think the stubs have it because the stub generator puts it in.

@gvanrossum
Copy link
Member

Amazing!

@gvanrossum gvanrossum merged commit 15ec66c into python:master Oct 30, 2016
@TrueBrain TrueBrain deleted the doc-optional branch October 30, 2016 18:58
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.

2 participants