|
| 1 | +Contributor guide |
| 2 | +================= |
| 3 | + |
| 4 | +Contributions are welcome, and several things about this repository |
| 5 | +have been set up to make the process easier for everyone (including |
| 6 | +you!). |
| 7 | + |
| 8 | + |
| 9 | +Prerequisites |
| 10 | +------------- |
| 11 | + |
| 12 | +* Please use a code editor/IDE that supports `EditorConfig |
| 13 | + <https://editorconfig.org>`_. Most editors do nowadays, so you |
| 14 | + probably don't have to worry about it, but it will help to |
| 15 | + automatically apply some formatting and style rules. |
| 16 | + |
| 17 | +* Please make sure you have `pre-commit <https://pre-commit.com>`_ |
| 18 | + installed, and in your local checkout of this repository run |
| 19 | + ``pre-commit install`` to set up the pre-commit hooks. |
| 20 | + |
| 21 | +The following two tools are *required* for working with this |
| 22 | +repository: |
| 23 | + |
| 24 | +* `PDM <https://pdm-project.org/>`_ |
| 25 | + |
| 26 | +* `nox <https://nox.thea.codes/en/stable/>`_ |
| 27 | + |
| 28 | +You will also need at least one supported Python version. It is also |
| 29 | +recommended that you test against *all* the supported Python verisions |
| 30 | +before opening a pull request; you can use `PDM's Python installer |
| 31 | +<https://pdm-project.org/latest/usage/project/#install-python-interpreters-with-pdm>`_ |
| 32 | +to install any versions of Python you need. |
| 33 | + |
| 34 | + |
| 35 | +Local setup |
| 36 | +----------- |
| 37 | + |
| 38 | +Once you have the tools above installed, run the following in the root |
| 39 | +of your git checkout:: |
| 40 | + |
| 41 | + pdm install |
| 42 | + |
| 43 | +This will create a local virtual environment and install |
| 44 | +``webcolors`` and its dependencies. |
| 45 | + |
| 46 | + |
| 47 | +Testing |
| 48 | +------- |
| 49 | + |
| 50 | +To run the tests, use ``nox``:: |
| 51 | + |
| 52 | + nox --tags tests |
| 53 | + |
| 54 | +By default this will run against as many supported Python versions as |
| 55 | +you have installed. To select a single specific Python version, you |
| 56 | +can run:: |
| 57 | + |
| 58 | + nox --tags tests --python "3.11" |
| 59 | + |
| 60 | +You can also run the full CI suite locally by just invoking |
| 61 | +``nox``. This will run the tests, check the documentation, lint the |
| 62 | +code and check formatting, and build a package and perform checks on |
| 63 | +it. |
| 64 | + |
| 65 | +For more information about available tasks, run ``nox --list`` or read |
| 66 | +the file ``noxfile.py`` in the root of your source checkout, or the |
| 67 | +testing documentation in the file ``docs/conformance.rst``. |
| 68 | + |
| 69 | + |
| 70 | +Code style |
| 71 | +---------- |
| 72 | + |
| 73 | +The pre-commit hooks will auto-format code with `isort |
| 74 | +<https://pycqa.github.io/isort/>`_ and `Black |
| 75 | +<https://black.readthedocs.io/>`_. Many editors and IDEs also support |
| 76 | +auto-formatting with these tools every time you save a file. The CI |
| 77 | +suite will disallow any code that does not follow the isort/Black |
| 78 | +format. |
| 79 | + |
| 80 | +All code must also be compatible with all supported versions of |
| 81 | +Python. |
| 82 | + |
| 83 | + |
| 84 | +Other guidelines |
| 85 | +---------------- |
| 86 | + |
| 87 | +* If you need to add a new file of code, please make sure to put a |
| 88 | + license identifier comment near the top of the file. You can copy |
| 89 | + and paste the license identifier comment from any existing file, |
| 90 | + where it looks like this: |
| 91 | + ``# SPDX-License-Identifier: BSD-3-Clause`` |
| 92 | + |
| 93 | +* Documentation and tests are not just recommended -- they're |
| 94 | + required. Any new file, class, method or function must have a |
| 95 | + docstring and must either include that docstring (via autodoc) in |
| 96 | + the built documentation, or must have manually-written documentation |
| 97 | + in the ``docs/`` directory. Any new feature or bugfix must have |
| 98 | + sufficient tests to prove that it works, and the test coverage |
| 99 | + report must come out at 100%. The CI suite will fail if test |
| 100 | + coverage is below 100%, if there's any code which doesn't have a |
| 101 | + docstring, or if there are any misspelled words in the documentation |
| 102 | + (and if there's a word the spell-checker should learn to recognize, |
| 103 | + add it to ``docs/spelling_wordlist.txt``). |
0 commit comments