Skip to content
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

gh-98963: Add a note to the error for property subclasses without __doc__ #99058

Closed
wants to merge 3 commits into from

Conversation

encukou
Copy link
Member

@encukou encukou commented Nov 3, 2022

Subclasses created using the C API don't get __dict__, which means their __doc__ can't be set for each property separately. The __doc__ descriptor from property itself is shadowed by the subclass's docstring.

This edge case isn't really worth mentioning in the docs. This adds a note that should guide anyone encountering the issue to the right fix.

The newfangled __notes__ mechanism is as non-invasive as it gets -- it even retains the original exception object -- while getting the information to the surprised user.
(The message is longer than typical error messages, but IMO it's better to explain here than in the docs, where 99%+ of the readers don't need it.)

…ut __doc__

Subclasses created using the C API don't get __dict__, which means their
__doc__ can't be set for each property separately. The __doc__
descriptor from `property` itself is shadowed by the subclass's docstring.

This edge case isn't really worth mentioning in the docs. This adds a note
that should guide anyone encountering the issue to the right fix.
@encukou encukou marked this pull request as ready for review May 25, 2023 14:49
@gpshead
Copy link
Member

gpshead commented Jun 3, 2023

See #105262 - I'm restoring the previous behavior.

@gpshead
Copy link
Member

gpshead commented Jun 5, 2023

we've reverted the behavior. if we re-attempt this behavior change it'll presumably be a deprecation cycle first (warning) followed ultimately by an error in which something like this note would make sense. (good idea!)

@gpshead gpshead closed this Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants