-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
DOC: Run all doctests #62988
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
base: main
Are you sure you want to change the base?
DOC: Run all doctests #62988
Conversation
|
Yikes. I like the env variable approach more than then set_module-on-all-classmethods approach. Is there a "hope for a fix upstream" option? |
It seems feasible. The current behavior is due to which was added in the commit python/cpython@8485b56. I don't think I can find any discussion due to the age here, so not clear if the added line was thought through. Removing the A fix also seems possible in pytest - it overrides if inspect.isfunction(object) and "." in object.__qualname__:
return Trueis a reliable way to ignore checking the module of attributes on a class. The class would only be recursed if it was already found to have the right Not sure if either CPython or pytest would be on board with an upstream fix - one possible counter is that we shouldn't have a class's Edit: Super hacky, but we can also do this ourselves. def pytest_sessionstart(session):
import doctest, inspect
orig = doctest.DocTestFinder._from_module
def _from_module(self, module, object):
if inspect.isfunction(object) and "." in object.__qualname__:
return True
return orig(self, module, object)
doctest.DocTestFinder._from_module = _from_module |
|
It's unfortunate, but I'm OK with your It would be interesting to survey other projects that override |
…python_scalars
…ndas into renable_doctests
doc/source/whatsnew/vX.X.X.rstfile if fixing a bug or adding a new feature.It appears that if the
__module__value of the class does not agree with the__module__value of the methods, then the doctests do not run.Still
verifying if this is correct andinvestigating the best way to handle it.Edit: Indeed, CI is showing many wrong docstrings due to this.
There are two approaches I am considering here:
__module__values when we run the doctests. The downside is that we'd need to not have the__module__value appear in any of the example's output because e.g.pandas.Serieswould appear aspandas.core.series.Series.__module__on all class methods via theset_moduledecorator usinginspect(automatically iterating through class methods and modifying the__module__attribute). This would increase import time (not sure by how much) and it wouldn't work on cdef classes.