@@ -95,14 +95,31 @@ To build the documentation run:
9595 To view the built documentation, open the file ``sphinx/_build/index.html `` in a
9696browser.
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+
98116Tests
99117-----
100118
101119Running 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+
124149For 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
136164Coverage
@@ -188,3 +216,9 @@ should go. If you are unsure, ask in the pull request.
188216
189217Please don't open pull requests with breaking changes unless this has been
190218discussed 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