Skip to content

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

Merged
gvanrossum merged 2 commits intopython:masterfrom
TrueBrain:doc-optional
Oct 30, 2016
Merged

Consider __doc__ always Optional. Fixes issues surfaced with python/mypy#2380.#641
gvanrossum merged 2 commits intopython:masterfrom
TrueBrain:doc-optional

Conversation

@TrueBrain
Copy link
Copy Markdown
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.

Comment thread README.md Outdated
MAXYEAR = ... # type: int
MINYEAR = ... # type: int
__doc__ = ... # type: str
__doc__ = ... # type: Optional[str]
Copy link
Copy Markdown
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).

Comment thread stdlib/2/abc.pyi Outdated
# TODO: FrozenSet
__abstractmethods__ = ... # type: Set[Any]
__doc__ = ... # type: str
__doc__ = ... # type: Optional[str]
Copy link
Copy Markdown
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
Copy Markdown
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
hswong3i pushed a commit to alvistack/python-typeshed that referenced this pull request Aug 22, 2025
Closes: python#544

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
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