Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-129578: Fix collection of doctests from wrapped objects #129579

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

viccie30
Copy link
Contributor

@viccie30 viccie30 commented Feb 2, 2025

Add follow_wrapped parameter to doctest.DocTestFinder.find to
unwrap objects before searching them for doctests.

Add functools.update_wrapper call to constructor of
functools.singledispatchmethod to let it be searched by doctest.


📚 Documentation preview 📚: https://cpython-previews--129579.org.readthedocs.build/

@picnixz
Copy link
Member

picnixz commented Feb 2, 2025

Is there a way to do it without applying update_wrapper? I'm not entirely sure that it can be applied in all situations and the omission was not something deliberate. If update_wrapper is needed, we may also have a dedicated issue for that as this may change runtime assumptions for downstream users, so more testing may be needed (independently of doctest itseff).

cc @serhiy-storchaka

@viccie30
Copy link
Contributor Author

viccie30 commented Feb 2, 2025

Is there a way to do it without applying update_wrapper? I'm not entirely sure that it can be applied in all situations and the omission was not something deliberate. If update_wrapper is needed, we may also have a dedicated issue for that as this may change runtime assumptions for downstream users, so more testing may be needed (independently of doctest itseff).

It might be possible by letting doctest use an object's __doc__ attribute always and setting that explicitly in the constructor of singledispatchmethod. Right now, doctest only collects docstrings from function-like and class objects.

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.

2 participants