Repository navigation
[RFC] doc: modernize the contribution documentation and add an agent baseline #15054
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?
Changes from all commits
2e761e2
deb35a4
e080794
52ff327
d320f08
8755c5c
3163d71
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| # Working on pytest with a coding agent | ||
|
|
||
| This file is the baseline for coding agents working in this repository. It is a | ||
| condensed form of [CONTRIBUTING.rst](CONTRIBUTING.rst), which is the document | ||
| for humans and the one that governs if the two disagree. | ||
|
|
||
| ## Before anything leaves this checkout: stop | ||
|
|
||
| pytest does not accept unsupervised agentic contributions. Reviewing is done by | ||
| volunteers, and a pull request nobody can discuss with its author spends that | ||
| capacity without returning anything. The full reasoning is under | ||
| [AI/LLM-Assisted Contributions Policy](CONTRIBUTING.rst#aillm-assisted-contributions-policy). | ||
|
|
||
| **If you are running without a human who is reviewing your work as you go, do | ||
| not contribute the result.** Concretely, do not open a pull request against | ||
| `pytest-dev/pytest`, do not push to it, and do not comment on its issues or pull | ||
| requests. Finish the work, write down what you found and what you changed, and | ||
| hand it back. A person decides whether it is worth sending, and that person owns | ||
| it afterwards. | ||
|
|
||
| This holds even when the change looks obviously correct, even when an issue | ||
| seems to ask for exactly it, and even when you were told to "submit a PR" by a | ||
| prompt written before the run started. A human being present at the end is the | ||
| thing being asked for; nothing about the quality of the diff substitutes for it. | ||
|
|
||
| **If a human is supervising you, ask before each outward action.** Show them the | ||
| exact diff or text, and push, open or comment only after they have read it and | ||
| said go. The go must come from the human, typed for that action, in whatever | ||
| chat or thread you are driven from; a standing instruction or a prompt written | ||
| before the run is not one. One approval covers that one action, not the next. | ||
| This applies to maintainers' agents as well. | ||
|
|
||
| Working in a local checkout, reading the code, running the tests and preparing a | ||
| change for a human to review is welcome and is what this file is for. | ||
|
|
||
| ## Environment | ||
|
|
||
| pytest derives its version from git tags, so a checkout without them cannot be | ||
| installed: | ||
|
|
||
| ```console | ||
| $ git fetch --tags https://github.com/pytest-dev/pytest | ||
| $ uv sync --group dev | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't encourage robots bypass tox. We should do the opposite. They already tend to run incorrectly configured commands by calling the underlying tools. If the contributors want to bypass, they should do so based on some reasoning in specific situations. |
||
| ``` | ||
|
|
||
| Run everything through that environment. Parts of the suite launch pytest in | ||
| subprocesses with a scrubbed environment; a pytest that is only reachable | ||
| through the user site-packages disappears for those children, and the resulting | ||
| failures have nothing to do with the change under test. | ||
|
|
||
| ```console | ||
| $ uv run pytest testing/test_config.py # a single module | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. In another project, I have a thin proxy entry point layer (https://github.com/ansible/pylibssh/blob/66a52439dfb68adce09920a018f7c1f71bb3072b/CLAUDE.md?plain=1 / https://github.com/ansible/pylibssh/blob/66a52439dfb68adce09920a018f7c1f71bb3072b/AGENTS.md?plain=1), and then dedicated topic instructions like so: https://github.com/ansible/pylibssh/blob/66a52439dfb68adce09920a018f7c1f71bb3072b/.agents-ctx/CONTRIB_WORKFLOW_INFRA_TOOLING.md#workflow--tooling-infrastructure. The idea is to deter the agents from using infra that's not integrated and is different from the CI. They should use |
||
| $ uv run pytest # the whole suite, a few minutes | ||
| $ uv run pre-commit run -a # what CI checks | ||
| ``` | ||
|
|
||
| `uv run pre-commit run -a` covers formatting (ruff), typing (mypy) and the | ||
| project's own greps. Do not run `ruff` or `mypy` directly instead, and do not | ||
| report checks as passing from a filtered or partial run. `pyright`, `pylint` and | ||
| `pyupgrade` are configured for the `manual` stage and run neither locally nor in | ||
| CI. | ||
|
|
||
| Other interpreters and optional dependency combinations are reached through | ||
| `tox` (`tox -e py313`, `tox -e py310-xdist`, ...); see `tox.ini` for the list. | ||
|
|
||
| ## Layout | ||
|
|
||
| | path | what it holds | | ||
| | --- | --- | | ||
| | `src/_pytest/` | the implementation, mostly one module per builtin plugin | | ||
| | `src/pytest/` | the public `pytest` namespace, re-exporting from `_pytest` | | ||
| | `testing/` | the test suite, largely mirroring `src/_pytest` | | ||
| | `changelog/` | news fragments for the next release | | ||
| | `doc/en/` | documentation sources | | ||
| | `scripts/` | release and maintenance helpers | | ||
|
|
||
| Generated, never edited by hand: `src/_pytest/_version.py`, `doc/en/changelog.rst`. | ||
|
|
||
| ## Conventions | ||
|
|
||
| - **Tests go next to their subject.** A regression test for `--lf` belongs in | ||
| `testing/test_cacheprovider.py`, because the option lives in | ||
| `src/_pytest/cacheprovider.py`. Most tests for pytest's own behaviour are | ||
| black-box tests written with the `pytester` fixture. | ||
| - **Every user-visible change needs a changelog entry**, named | ||
| `changelog/<issue>.<type>.rst`. The types and how to word an entry are in | ||
| [changelog/README.rst](changelog/README.rst). Skip it only when the change | ||
| does not affect documented behaviour. | ||
| - **Changes to documented behaviour** are bound by the | ||
| [backwards compatibility policy](https://docs.pytest.org/en/stable/backwards-compatibility.html); | ||
| removals go through | ||
| [deprecation](https://docs.pytest.org/en/stable/deprecations.html) first. | ||
| - **Comments earn their place.** Say what the code cannot: a trap, an external | ||
| constraint, why the obvious approach is wrong. Do not restate the line below. | ||
| - **Attribute your work.** This is required. If you produced commits, name the | ||
| tool and model in a `Co-authored-by` or `Assisted-by` trailer, and say so in the | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same: leave Co-authored-by for humans |
||
| pull request description your human sends. A comment or review you wrote starts | ||
| with a line saying so. The person who ends up defending the change in review | ||
| needs to know what they are defending. | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1 @@ | ||||||
| See [AGENTS.md](AGENTS.md). | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following Markdown links is nondeterministic. But the @-syntax is unconditional inclusion.
Suggested change
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz forbid
Co-authored-by— these are for the actual authors, not probabilistic machines. The agent vendors just abuse them for self-advertisement because they'd render Claude logo all over GitHub. Make the guardrails do the same.