Skip to content

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.

README.md Outdated
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).

stdlib/2/abc.pyi Outdated
# 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
hswong3i pushed a commit to alvistack/python-typeshed that referenced this pull request Aug 22, 2025
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