Debian Codegraph @

CONTRIBUTING.rst

raw ◀ ▶
1 Debian patch touch this file
1 .. Forward declarations for all the custom interpreted text roles that
2 Sphinx defines and that are used below. This helps Sphinx-unaware tools
3 (e.g. rst2html, PyPI's and GitHub's renderers, etc.).
4 .. role:: doc
5 .. role:: ref
6
7
8 Contributors' Guide
9 ===================
10
11 Bug reports, feature requests, patches, and other contributions are warmly welcomed.
12 Contribution should be as easy and friendly as possible.
13 Below are a few guidelines contributors should follow to facilitate the process.
14
15
16 Getting Started
17 ---------------
18
19 - `Create a GitHub account <https://github.com/join>`__ if you don't have one
20 already.
21
22 - Search through the `tracker <https://github.com/jab/bidict/issues?q=>`__
23 to see if an issue or pull request has already been created for what you're interested in.
24 If so, feel free to add comments to it or just hit the "subscribe" button to follow progress.
25 If not, you can post in the
26 `GitHub Discussions forum <https://github.com/jab/bidict/discussions>`__,
27 or go ahead and `create a new issue <https://github.com/jab/bidict/issues/new>`__:
28
29 - Clearly describe the issue giving as much relevant context as possible.
30
31 - If it is a bug, include reproduction steps,
32 all known environments in which the bug is exhibited,
33 and ideally a failing test case.
34
35 - If you would like to contribute a patch,
36 make sure you've `created your own fork <https://github.com/jab/bidict/fork>`__
37 and have cloned it to your computer.
38
39
40 Making Changes
41 --------------
42
43 - To set up a development environment:
44
45 - If you have `Nix <https://nixos.org>`__, run ``nix develop``
46 from within your clone to start a shell where all supported
47 Python versions as well as ``prek`` are installed and added
48 to your PATH. This also pins ``uv`` to the flake-provided
49 default Python when initializing ``.venv``.
50
51 - Otherwise, manually ensure you have `uv <https://docs.astral.sh/uv/>`__,
52 `prek <https://github.com/j178/prek>`__, and at least the latest
53 `stable Python version <https://python.org/downloads/>`__ installed
54 and on your PATH.
55
56 - Run ``./init_dev_env``
57
58 This installs the ``prek``-based pre-commit hook in your clone,
59 and creates a virtualenv with all the development dependencies installed.
60
61 - Note that `prek <https://github.com/j178/prek>`__
62 is used to help achieve uniform code style and quality standards
63 at commit time.
64
65 - Create a topic branch off of ``main`` for your changes:
66 ``git checkout -b <topic> main``
67
68 - Make commits of logical units.
69
70 - Match the existing code style and quality standards.
71 If you're adding a feature, include accompanying tests and documentation
72 demonstrating its correctness and usage.
73
74 - Run the tests locally with `tox <https://tox.readthedocs.io>`__
75 to make sure they pass for all supported Python versions
76 (see ``envlist`` in ``tox.ini`` for the complete list).
77 If you do not have all the referenced Python versions available locally,
78 you can also push the changes on your branch to GitHub
79 to automatically trigger a new
80 `GitHub Actions <https://github.com/jab/bidict/actions>`__ build,
81 which should run the tests for all supported Python versions.
82 Testing your changes with GitHub Actions will require approval
83 from a project admin the first time you submit a PR.
84
85 - Create a concise but comprehensive commit message in the following style::
86
87 Include an example commit message in CONTRIBUTING guide #9999
88
89 Without this patch the CONTRIBUTING guide would contain no examples of
90 a model commit message. This is a problem because the contributor is left
91 to imagine what the commit message should look like and may not get it
92 right. This patch fixes the problem by providing a concrete example.
93
94 The first line is an imperative statement summarizing the changes with an
95 issue number from the tracker. The body describes the behavior without
96 the patch, why it's a problem, and how the patch fixes the problem.
97
98
99 Running Tests and Checks
100 ------------------------
101
102 The commands below assume you have an active development environment,
103 set up per the steps above.
104 Commands that run against the ``./init_dev_env`` virtualenv (such as ``pytest``)
105 can be prefixed with ``uv run``
106 or run after activating ``.venv``.
107 Note, however, that ``prek`` — used by the lint, format, and style hooks,
108 including via ``tox -e lint`` — is provided by the ``nix develop`` shell
109 (or your own PATH, if you installed it manually per the setup steps above),
110 not by the ``./init_dev_env`` virtualenv,
111 so run those from within ``nix develop``
112 (or otherwise ensure ``prek`` is on your PATH).
113
114 - Run the test suite on your current Python: ``pytest``
115
116 - Run a single test:
117 ``pytest tests/test_bidict.py::test_frozenbidicts_hashable``
118
119 - Run the tests for every supported Python version: ``tox``
120 (see ``envlist`` in ``tox.ini`` for the list).
121
122 - Type-check the code: ``ty check``
123
124 - Run all the lint, format, and style hooks: ``prek run --all-files``
125 (equivalently, ``tox -e lint``).
126
127 - Build the docs: ``tox -e docs``.
128
129 Note that the test suite (configured under ``[tool.pytest]`` in
130 ``pyproject.toml``) executes the doctests in every module's docstrings
131 **as well as** the code blocks in ``docs/*.rst`` files. In other words,
132 example code in docstrings and docs is run as part of the tests, so be sure
133 to keep it correct and up to date.
134
135
136 Most of bidict's tests are property-based,
137 written using `Hypothesis <https://hypothesis.works>`__.
138 The bulk of the suite lives in ``tests/test_bidict.py``,
139 centered on ``BidictStateMachine``
140 (a `stateful <https://hypothesis.readthedocs.io/en/latest/stateful.html>`__
141 ``RuleBasedStateMachine``)
142 that checks bidict's invariants against a simpler reference model,
143 with user-defined bidict subclass fixtures in ``tests/bidict_test_fixtures.py``.
144 When adding behavior,
145 prefer extending these properties and invariants
146 (and adding doctests where they help document usage)
147 over adding one-off, example-based tests.
148
149
150 Documentation and Prose Style
151 -----------------------------
152
153 Prose in bidict's Markdown and reStructuredText documents
154 (this file, the ``*.rst`` files under ``docs/``, etc.)
155 follows `Semantic Line Breaks <https://sembr.org>`__ (SemBr):
156 start a new line after each sentence,
157 and optionally at other natural boundaries between clauses or phrases,
158 rather than hard-wrapping at a fixed column width
159 or placing an entire paragraph on a single line.
160 Because both Markdown and reStructuredText collapse
161 a single line break within a paragraph into a space,
162 this keeps the rendered output unchanged
163 while making diffs smaller and easier to review.
164 This convention applies to these prose documents only,
165 not to code, code comments, docstrings, or commit messages.
166
167
168 Submitting Changes
169 ------------------
170
171 - Push your changes to a topic branch in your fork of the repository:
172 ``git push --set-upstream origin <topic>``
173
174 - Submit a pull request providing any additional relevant details necessary.
175
176 - Acknowledgment should typically be fast
177 but please allow 1-2 weeks for a full response / code review.
178
179 - The code review process often involves some back-and-forth
180 to get everything right before merging.
181 This is typical of quality software projects that accept patches.
182
183 - All communication should be supportive and appreciative of good faith efforts to contribute,
184 creating a welcoming and inclusive community.
185
186
187 Sponsoring
188 ----------
189
190 .. Some of the following badges are duplicated on other pages.
191 Would use `.. include::` but GitHub's renderer doesn't support it.
192
193 Bidict is the product of thousands of hours of my unpaid work
194 over the 20 years that I've been the sole maintainer.
195
196 If bidict has helped you or your company accomplish your work,
197 please sponsor my work through one of the following,
198 and/or ask your company to do the same:
199
200 - `GitHub <https://github.com/sponsors/jab>`__
201 - `PayPal <https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=jabronson%40gmail%2ecom&lc=US&item_name=Sponsor%20bidict>`__
202 - `Tidelift <https://tidelift.com>`__
203 - `thanks.dev <https://thanks.dev>`__
204 - `Gumroad <https://gumroad.com/l/bidict>`__
205 - `a support engagement with my LLC <https://bidict.readthedocs.io/#enterprise-support>`__
206
207 If you're not sure which to use, GitHub is an easy option,
208 especially if you already have a GitHub account.
209 Just choose a monthly or one-time amount, and GitHub handles everything else.
210 Your bidict sponsorship on GitHub will automatically go
211 on the same regular bill as any other GitHub charges you pay for.
212 PayPal is another easy option for one-time contributions.
213
214 See the following for rationale and examples of companies
215 supporting the open source projects they depend on
216 in this manner:
217
218 - `<https://engineering.atspotify.com/2022/04/announcing-the-spotify-foss-fund/>`__
219 - `<https://blog.sentry.io/2021/10/21/we-just-gave-154-999-dollars-and-89-cents-to-open-source-maintainers>`__
220 - `<https://engineering.indeedblog.com/blog/2019/07/foss-fund-six-months-in/>`__
221
222 .. - `<https://sethmlarson.dev/blog/people-in-your-software-supply-chain>`__
223 .. - `<https://www.cognitect.com/blog/supporting-open-source-developers>`__
224 .. - `<https://vorpus.org/blog/the-unreasonable-effectiveness-of-investment-in-open-source-infrastructure/>`__
225
226
227 Code of Conduct
228 ---------------
229
230 All participation in this project should respect the
231 :doc:`code-of-conduct`. [#fn-coc]_
232
233 By participating, you are expected to honor this code.
234
235 .. [#fn-coc] `<https://bidict.readthedocs.io/code-of-conduct.html>`__ | `<CODE_OF_CONDUCT.rst>`__