Skip to content

docs: add docstrings to public functions in _pytest/main.py#14314

Open
Aliipou wants to merge 2 commits intopytest-dev:mainfrom
Aliipou:docs/add-docstrings-to-main-py
Open

docs: add docstrings to public functions in _pytest/main.py#14314
Aliipou wants to merge 2 commits intopytest-dev:mainfrom
Aliipou:docs/add-docstrings-to-main-py

Conversation

@Aliipou
Copy link

@Aliipou Aliipou commented Mar 22, 2026

Summary

Closes #12979.

Adds Sphinx-compatible docstrings to functions in src/_pytest/main.py (lines 245-490) that were missing them.

Changes

  • validate_basetemp: documents validation logic, parameters, return value, and exception raised
  • pytest_cmdline_main: describes its role as the default hook implementation
  • pytest_collection: documents that it triggers test collection via Session.perform_collect()
  • pytest_runtestloop: describes iteration over test items and early-exit conditions
  • pytest_ignore_collect: enumerates all conditions under which a path is skipped
  • pytest_collect_directory: describes the Dir node it creates
  • pytest_collection_modifyitems: documents the --deselect filtering logic

Note: Earlier attempts (#13090, #13091) were closed without being merged.

Generated with Claude Code

Aliipou and others added 2 commits March 22, 2026 21:03
Fixes pytest-dev#12658.

The hooks `pytest_collectstart`, `pytest_make_collect_report`,
`pytest_itemcollected`, `pytest_collectreport`, and `pytest_deselected`
were listed under the "Reporting hooks" section in the reference docs.
These hooks are collection-related and belong in the "Collection hooks"
section.

This commit moves them to the end of the Collection hooks section with
a brief description, and removes them from the Reporting hooks section.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Closes pytest-dev#12979.

Adds Sphinx-compatible docstrings to several functions in
`src/_pytest/main.py` (lines 245-490) that were missing them:

- `validate_basetemp`: documents the validation logic, parameters,
  return value, and the exception it raises.
- `pytest_cmdline_main`: describes its role as the default hook
  implementation that runs the test session.
- `pytest_collection`: documents that it triggers test collection
  via `Session.perform_collect()`.
- `pytest_runtestloop`: describes the iteration over test items
  and the early-exit conditions.
- `pytest_ignore_collect`: enumerates all conditions under which
  a path is skipped.
- `pytest_collect_directory`: describes the `Dir` node it creates.
- `pytest_collection_modifyitems`: documents the `--deselect`
  filtering logic.

Co-Authored-By: Claude Sonnet 4.6 <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.

Add Missing Docstrings and inline comments to pytest/src/_pytest/main.py (Lines 245-490)

1 participant