Skip to content

Don't evaluate descriptors or import __main__.py during docstring collection - #79

Merged
Elias Freider (freider) merged 1 commit into
modal-labs:mainfrom
Bortlesboat:fix-docstring-collection-errors
Nov 4, 2026
Merged

Elias Freider (freider) merged 1 commit into
modal-labs:mainfrom
Bortlesboat:fix-docstring-collection-errors

Conversation

@Bortlesboat

Copy link
Copy Markdown
Contributor

Docstring collection used inspect.getmembers, which calls every descriptor's __get__, and it tried to import __main__.py, which clashes with the running pytest; --doctest-modules does neither. This walks __dict__ the way DocTestFinder does (unwrapping staticmethod/classmethod) and skips __main__.py. Added tests for both; uv run pytest tests passes.

Fixes #76

…lection

Walk __dict__ like doctest.DocTestFinder instead of inspect.getmembers(),
which calls every descriptor's __get__, and skip __main__.py the way
pytest's doctest plugin does.

Fixes modal-labs#76
@freider
Elias Freider (freider) force-pushed the fix-docstring-collection-errors branch from 794e6ff to 7795650 Compare November 4, 2026 20:05
@freider

Copy link
Copy Markdown
Collaborator

Thanks!

@freider Elias Freider (freider) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@freider
Elias Freider (freider) merged commit ac7022b into modal-labs:main Nov 4, 2026
5 checks passed
Elias Freider (freider) added a commit that referenced this pull request Nov 5, 2026
#79 switched docstring collection from inspect.getmembers() (alphabetical)
to walking __dict__ (definition order), and #75 landed concurrently with a
consecutive-lines assertion written against the old alphabetical order.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

Docstring collection runs descriptors (inspect.getmembers) and errors on __main__.py, where --doctest-modules does neither

2 participants