Skip to content

Conversation

@bharel
Copy link
Contributor

@bharel bharel commented Jan 9, 2020

According to the mailing list discussion, fixed dict's documentation to account for get() not calling __missing__ and moved __missing__ from the data model to dict as it's a dict-only method and not part of the Mapping ABC.

@bharel
Copy link
Contributor Author

bharel commented Feb 21, 2020

bump

@csabella csabella requested a review from terryjreedy May 23, 2020 18:31
Copy link
Member

@terryjreedy terryjreedy left a comment

Choose a reason for hiding this comment

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

My first thought is that the entry should stay where it is, though something may need to be added somewhere. Special method should not have to be part of an ABC to be documented in the special methods doc. This section long predated ABCs. I will have to look at the linked discussion when I have more time. So I don't know what change, if any, to suggest at the moment.

@bharel
Copy link
Contributor Author

bharel commented May 24, 2020

Special method should not have to be part of an ABC to be documented in the special methods doc.

Thing is, I'm not implying any opinion on whether it should be there or not.
What I I'm saying, is that it should be consistent.

At the moment, you have __reduce__ in pickle's docs, __subclasshook__ in abc's docs, and other dunders at their appropriate or relevant places. You don't have all dunders in the same location, apart from those relevant to all objects and classes.

Continuing with that logic, __missing__ should probably be in dict's docs, as that's the only location where it's relevant. Otherwise the documentation is inconsistent.

Furthermore - it's specifically dict.__missing__, not object.__missing__. The docs are misleading in the current state. (Discussion @ mailing list)

As a side note, the PR changes dict.get documentation as well.

@AlexWaygood AlexWaygood changed the title bpo-39267: Fix dict's __missing__ documentation gh-83448: Fix dict's __missing__ documentation Oct 30, 2022
@slateny
Copy link
Contributor

slateny commented Dec 10, 2022

Per Guido on the mailing list, maybe @rhettinger can suggest something (seeing that you reviewed/merged #17910 as well).


.. method:: __missing__(key)

Not implemented by default. Called by :class:`dict`\ .\ :meth:`__getitem__`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Not implemented by default. Called by :class:`dict`\ .\ :meth:`__getitem__`
Not implemented by default. Called by :meth:`dict.__getitem__`

@merwok
Copy link
Member

merwok commented Mar 1, 2024

I agree about not moving the entry.
Other magic methods are also documented as object.__iter__ and so on. In this context it means «some object», not «the object type». Improving that would be a separate issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting changes docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

8 participants