Skip to content

Commit 0778709

Browse files
authored
Updates to contribution instructions and pull request template (#914)
1 parent c3783d3 commit 0778709

2 files changed

Lines changed: 39 additions & 3 deletions

File tree

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ task is not relevant or leave empty when in doubt.
3030
-->
3131

3232
- [ ] Did you read the [contributing guideline](https://github.com/omni-us/jsonargparse/blob/main/CONTRIBUTING.rst)?
33+
- [ ] If you used a **coding agent**, did you fully understand and validate all generated code and ensure it follows the contributing guidelines?
3334
- [ ] Did you update **the documentation**? (readme and public docstrings)
3435
- [ ] Did you write **unit tests** such that there is 100% coverage on related code? (required for bug fixes and new features)
3536
- [ ] Did you verify that new and existing **tests pass locally**?
37+
- [ ] If this is a **bug fix**, did you verify that the **tests fail without the code fix**?
3638
- [ ] Did you make sure that all changes preserve **backward compatibility**?
3739
- [ ] Did you update **the CHANGELOG** including a pull request link? (not for typos, docs, test updates, or minor internal changes/refactors)

CONTRIBUTING.rst

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,31 @@ To build the documentation run:
9595
To view the built documentation, open the file ``sphinx/_build/index.html`` in a
9696
browser.
9797

98+
Code conventions
99+
----------------
100+
101+
**Public vs. private naming**
102+
103+
Most module filenames start with ``_``, meaning they are private implementation
104+
details. For objects within modules, the ``_`` prefix indicates the object is
105+
only used within that same module. An object without a ``_`` prefix may be
106+
imported by other modules but that does not make it public — it is simply
107+
internal to the package. The only truly public objects are those listed in
108+
``jsonargparse.__all__`` and ``jsonargparse.typing.__all__``.
109+
110+
**Type annotations and docstrings**
111+
112+
New source code should be fully type annotated. Docstrings should follow `Google
113+
style
114+
<https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings>`__.
115+
98116
Tests
99117
-----
100118

101119
Running the unit tests can be done either using `pytest
102120
<https://docs.pytest.org/>`__ or `tox
103-
<https://tox.readthedocs.io/en/stable/>`__. The tests are also installed with
104-
the package and can be run in a non-development environment. Also pre-commit
105-
runs some additional tests.
121+
<https://tox.readthedocs.io/en/stable/>`__. Also pre-commit runs some additional
122+
tests.
106123

107124
.. code-block:: bash
108125
@@ -121,6 +138,14 @@ the main package. For example, for v4.47.0 run:
121138
pip install jsonargparse_tests==4.47.0
122139
python -m jsonargparse_tests
123140
141+
All contributed features and bug fixes must include tests. For bug fixes, ensure
142+
the test fails without the code fix. Almost always tests should exercise only
143+
the public API. Testing internal functions directly is rarely justified and
144+
should be avoided. For tests involving signatures, define the classes and
145+
functions used at the global module scope. Jsonargparse is not intended to
146+
support dynamically defined classes and functions, so there is no value in
147+
testing such cases.
148+
124149
For maintainable tests:
125150

126151
- Prefer ``pytest.mark.parametrize`` when the same test logic is exercised with
@@ -131,6 +156,9 @@ For maintainable tests:
131156
harder to read.
132157
- Keep setup separate from assertions so each test clearly shows the behavior
133158
being verified.
159+
- The pytest output must be clean. If a test causes log output, the logs must
160+
be captured and asserted using the ``logger`` fixture and ``capture_logs``
161+
context manager from ``conftest.py``.
134162

135163

136164
Coverage
@@ -188,3 +216,9 @@ should go. If you are unsure, ask in the pull request.
188216

189217
Please don't open pull requests with breaking changes unless this has been
190218
discussed and agreed upon in an issue.
219+
220+
Contributions using coding agents are welcome. However, any agent-generated
221+
code must be fully understood by the submitter and must make sense and follow
222+
these contributing guidelines. Always ask the agent to read and follow these
223+
guidelines. Also ask to read ``.github/PULL_REQUEST_TEMPLATE.md`` so that the
224+
tasks before submitting are covered.

0 commit comments

Comments
 (0)