Skip to content

Commit 8bb3d92

Browse files
committed
Copier Template: Add AI guidance.
1 parent a6a2895 commit 8bb3d92

4 files changed

Lines changed: 119 additions & 0 deletions

File tree

documentation/contribution.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@ Guidance and Standards
6565
* Although unncessary for non-maintainer contributions, additional background
6666
can be found in the :doc:`maintenance guide <common/maintenance>`.
6767

68+
Artificial Intelligence
69+
-------------------------------------------------------------------------------
70+
71+
* Contributions, which are co-authored by large language models (LLMs), are
72+
welcome, provided that they adhere to the project guidance and standards
73+
above and are, otherwise, of good quality.
74+
75+
* A more compact representation of the above guidance and standards, plus some
76+
other advice for these models, can be found in
77+
``.auxiliary/configuration/conventions.md``. You may link to this file from a
78+
``AGENTS.md``, ``CLAUDE.md``, ``CONVENTIONS.md`` file in the root of the
79+
project. These files are ignored by Git as we do not wish to pollute the
80+
root of the project with them in the upstream repository.
81+
6882
Resources
6983
-------------------------------------------------------------------------------
7084

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# General Advice
2+
3+
### Design
4+
5+
- Make classes lightweight. Prefer module-level functions over class methods.
6+
- Functions should not be more than 30 lines long. Refactor long functions.
7+
- Keep the number of function arguments small. Pass common state via
8+
data transfer objects (DTOs).
9+
- Use dependency injection to improve configuration and testability. Choose
10+
sensible defaults for injected dependencies to streamline normal development.
11+
- Prefer immutability wherever possible.
12+
13+
# Per-Language Advice
14+
15+
## Python
16+
17+
### Design and Idioms
18+
19+
- Target Python 3.10 and use idioms appropriate for that version
20+
(`match`..`case`, type unions via `|`, etc...).
21+
- Note the internal `__` subpackage which exposes imports used internally
22+
throughout the package (`cabc` alias for `collections.abc`, `enum`, `types`,
23+
`typx` alias for `typing_extensions`, etc...).
24+
- Do not pollute the module namespace with public imports. Either reference
25+
common imports from the `__` subpackage or alias module-level imports as
26+
private.
27+
- Do not use `__all__` to advertise the public API of a module. Name anything,
28+
which should not be part of this API, with a private name starting with `_`.
29+
30+
### Documentation and Annotations
31+
32+
- Pad inside of delimiter pairs with spaces. E.g., `( foo )` and not `(foo)`.
33+
Except in f-strings and `str.format` inputs.
34+
- Pad binary operators with spaces. E.g., `foo = 42` and not `foo=42`, `1 + 1`
35+
and not `1+1`, `[ 1 : -n ]` and not `[1:-n]`.
36+
- Docstrings look like `''' Space-padded headline inside of triple-single
37+
quotes. '''` and not `"""Double quotes and no spaces are hard to read."""`.
38+
- Use double-quoted strings for f-strings, `str.format` templates, and log
39+
messages. Otherwise, use single-quoted strings.
40+
- Add type hints for arguments, attributes, and return values.
41+
- Do not write "param spam" documentation which states the obvious. Only
42+
document non-obvious or complex behaviors on arguments and attributes.
43+
- Use PEP 593 `Annotated` with PEP 727 `Doc` for argument, attribute, and
44+
return value documentation, when necessary.
45+
- Use `TypeAlias` aliases to reuse complex annotations or expose them as part
46+
of the public API.
47+
48+
### Comments and Lines
49+
50+
- Do not strip comments from existing code unless directed to do so.
51+
- Do not describe obvious code with comments. Only comment on non-obvious or
52+
complex behaviors.
53+
- Leave TODO comments about uncovered edge cases, tests, and other future work.
54+
- Do not break function bodies with empty lines.
55+
- One empty line between attribute blocks and methods on classes.
56+
- Two empty lines between attribute blocks, classes, and functions on modules.
57+
- Split lines at 79 columns. Use parentheses for continuations and not
58+
backslashes.
59+
60+
### Lints and Tests
61+
62+
- Check your work by linting, ensuring that the package imports, running tests,
63+
and generating documentation.
64+
- Ignore any warnings, unless instructed otherwise. Focus only on errors and
65+
failures.
66+
- To run linters, use `hatch --env develop run linters`.
67+
- To run testers, use `hatch --env develop run testers`.
68+
- To generate documentation, use `hatch --env develop run docsgen`.
69+
- Do not write tests unless explicitly instructed to do so.
70+
71+
# Commits
72+
73+
- Use `git status` to ensure that all relevant changes are in the changeset to
74+
be committed.
75+
- Look at the previous five commit messages for guidance on message style.
76+
- Use present tense, imperative mood verbs to describe changes. E.g. "Fix" and
77+
*not* "Fixed".
78+
- The commit message should include a `Co-Authored-By:` field as its final
79+
line. The name of the author should be your model name. The email address
80+
should either be one which you have been designated to use or else a
81+
commonly-known no-reply address.
82+
83+
## Interactive Collaboration on User Terminal
84+
85+
- Do not commit until you have user approval to do so.
86+
- Add the `--no-gpg-sign` option to the `git commit` command to suppress GPG
87+
passphrase challenges. (These challenges conflict with the alternate console
88+
screen, managed by some CLI agents, resulting in an unusable terminal.)

template/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
.env
22
.*.swp
3+
AGENTS.md
4+
CLAUDE.md
5+
CONVENTIONS.md
36
__pycache__/
47
bugs/

template/documentation/contribution.rst.jinja

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ Guidance and Standards
7272
can be found in the `maintenance guide
7373
<https://github.com/emcd/python-project-common/blob/docs-1/documentation/common/maintenance.rst>`_.
7474

75+
Artificial Intelligence
76+
-------------------------------------------------------------------------------
77+
78+
* Contributions, which are co-authored by large language models (LLMs), are
79+
welcome, provided that they adhere to the project guidance and standards
80+
above and are, otherwise, of good quality.
81+
82+
* A more compact representation of the above guidance and standards, plus some
83+
other advice for these models, can be found in
84+
``.auxiliary/configuration/conventions.md``. You may link to this file from a
85+
``AGENTS.md``, ``CLAUDE.md``, ``CONVENTIONS.md`` file in the root of the
86+
project. These files are ignored by Git as we do not wish to pollute the
87+
root of the project with them in the upstream repository.
88+
7589
Resources
7690
-------------------------------------------------------------------------------
7791

0 commit comments

Comments
 (0)