Summary
Directory-level collection of docs/examples/ is broken — uv run pytest docs/examples/ --collect-only returns 0 items. Specifying individual files still works fine.
Cause
Introduced in d3d6040 (#742). The pytest_collect_file hook in docs/examples/conftest.py was changed to return None for non-skipped files, with the intention that pytest_pycollect_makemodule would handle collection instead.
However, pytest_pycollect_makemodule only fires for files matching the python_files pattern (test_*.py / *_test.py). Example files (e.g. hello_world.py) don't match, so during directory traversal they're silently dropped.
Fix
Restore an explicit collector return in pytest_collect_file for runnable examples. One-liner — return ExampleModule.from_parent(parent, path=file_path) instead of None at line 421.
Reproduction
uv run pytest docs/examples/ --collect-only
# collected 0 items
uv run pytest docs/examples/hello_world.py --collect-only
# collected 1 item ✓
Summary
Directory-level collection of
docs/examples/is broken —uv run pytest docs/examples/ --collect-onlyreturns 0 items. Specifying individual files still works fine.Cause
Introduced in d3d6040 (#742). The
pytest_collect_filehook indocs/examples/conftest.pywas changed to returnNonefor non-skipped files, with the intention thatpytest_pycollect_makemodulewould handle collection instead.However,
pytest_pycollect_makemoduleonly fires for files matching thepython_filespattern (test_*.py/*_test.py). Example files (e.g.hello_world.py) don't match, so during directory traversal they're silently dropped.Fix
Restore an explicit collector return in
pytest_collect_filefor runnable examples. One-liner — returnExampleModule.from_parent(parent, path=file_path)instead ofNoneat line 421.Reproduction