Skip to content
Myr

update contributing guide (#1584)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by GitHub · parent 76f376c · Browse files · 1 file+185 added−39 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+185 added−39 removed

  • other:+185 added−39 removed

1 file+185 added−39 removed

modified:CONTRIBUTING.rst+185 added-39 removed
1==========================1How to contribute to Click2==========================35Thanks for considering contributing to Click.4Thank you for considering contributing to Click!567Support questions8=================8-----------------910Please, don't use the issue tracker for this. Check whether the11``#pocoo`` IRC channel on Freenode can help with your issue. If your problem12is not strictly Click-specific, ``#python`` on Freenode is generally more13active. Also try searching or asking on `Stack Overflow`_ with the14``python-click`` tag.10Please, don't use the issue tracker for this. The issue tracker is a11tool to address bugs and feature requests in Click itself. Use one of12the following resources for questions about using Click or issues with13your own code:1416.. _Stack Overflow: https://stackoverflow.com/questions/tagged/python-click?sort=votes15- The ``#get-help`` channel on our Discord chat:16 https://discord.gg/t6rrQZH17- The mailing list flask@python.org for long term discussion or larger18 issues.19- Ask on `Stack Overflow`_. Search with Google first using:20 ``site:stackoverflow.com python click {search term, exception message, etc.}``2122.. _Stack Overflow: https://stackoverflow.com/questions/tagged/python-click?sort=linked232425Reporting issues19================26----------------2721- Under which versions of Python does this happen? This is even more important22 if your issue is encoding related.28Include the following information in your post:2924- Under which versions of Click does this happen? Check if this issue is fixed25 in the repository.30- Describe what you expected to happen.31- If possible, include a `minimal reproducible example`_ to help us32 identify the issue. This also helps check that the issue is not with33 your own code.34- Describe what actually happened. Include the full traceback if there35 was an exception.36- List your Python and Click. If possible, check if this issue is37 already fixed in the latest releases or the latest code in the38 repository.3940.. _minimal reproducible example: https://stackoverflow.com/help/minimal-reproducible-example414243Submitting patches28==================44------------------4530- Include tests if your patch is supposed to solve a bug, and explain clearly31 under which circumstances the bug happens. Make sure the test fails without32 your patch.46If there is not an open issue for what you want to submit, prefer47opening one for discussion before working on a PR. You can work on any48issue that doesn't have an open PR linked to it or a maintainer assigned49to it. These show up in the sidebar. No need to ask if you can work on50an issue that interests you.5134- Try to follow `PEP8 <http://legacy.python.org/dev/peps/pep-0008/>`_, but you35 may ignore the line-length-limit if following it would make the code uglier.52Include the following in your patch:5337- For features: Consider whether your feature would be a better fit for an38 `external package <https://click.palletsprojects.com/en/7.x/contrib/>`_54- Use `Black`_ to format your code. This and other tools will run55 automatically if you install `pre-commit`_ using the instructions56 below.57- Include tests if your patch adds or changes code. Make sure the test58 fails without your patch.59- Update any relevant docs pages and docstrings. Docs pages and60 docstrings should be wrapped at 72 characters.61- Add an entry in ``CHANGES.rst``. Use the same style as other62 entries. Also include ``.. versionchanged::`` inline changelogs in63 relevant docstrings.6440- For docs and bug fixes: Submit against the latest maintenance branch instead of master!65.. _Black: https://black.readthedocs.io66.. _pre-commit: https://pre-commit.com6742- Non docs or text related changes need an entry in ``CHANGES.rst``,43 and ``.. versionadded`` or ``.. versionchanged`` markers in the docs.6845Running the testsuite46---------------------69First time setup70~~~~~~~~~~~~~~~~7148You probably want to set up a `virtualenv49<https://virtualenv.readthedocs.io/en/latest/index.html>`_.72- Download and install the `latest version of git`_.73- Configure git with your `username`_ and `email`_.7451The minimal requirement for running the testsuite is ``py.test``. You can52install it with::75 .. code-block:: text7654 pip install pytest77 $ git config --global user.name 'your name'78 $ git config --global user.email 'your email'7956Then you can run the testsuite with::80- Make sure you have a `GitHub account`_.81- Fork Click to your GitHub account by clicking the `Fork`_ button.82- `Clone`_ the main repository locally.8358 py.test84 .. code-block:: text8560For a more isolated test environment, you can also install ``tox`` instead of61``pytest``. You can install it with::86 $ git clone https://github.com/pallets/click87 $ cd click8863 pip install tox89- Add your fork as a remote to push your work to. Replace90 ``{username}`` with your username.9165The ``tox`` command will then run all tests against multiple combinations of66Python versions and dependency versions.92 .. code-block:: text9394 git remote add fork https://github.com/{username}/click9596- Create a virtualenv.9798 .. code-block:: text99100 $ python3 -m venv env101 $ . env/bin/activate102103 On Windows, activating is different.104105 .. code-block:: text106107 > env\Scripts\activate108109- Install Click in editable mode with development dependencies.110111 .. code-block:: text112113 $ pip install -e . -r requirements/dev.txt114115- Install the pre-commit hooks.116117 .. code-block:: text118119 $ pre-commit install120121.. _latest version of git: https://git-scm.com/downloads122.. _username: https://help.github.com/en/articles/setting-your-username-in-git123.. _email: https://help.github.com/en/articles/setting-your-commit-email-address-in-git124.. _GitHub account: https://github.com/join125.. _Fork: https://github.com/pallets/click/fork126.. _Clone: https://help.github.com/en/articles/fork-a-repo#step-2-create-a-local-clone-of-your-fork127128129Start coding130~~~~~~~~~~~~131132- Create a branch to identify the issue you would like to work on. If133 you're submitting a bug or documentation fix, branch off of the134 latest ".x" branch.135136 .. code-block:: text137138 $ git checkout -b your-branch-name origin/7.x139140 If you're submitting a feature addition or change, branch off of the141 "master" branch.142143 .. code-block:: text144145 $ git checkout -b your-branch-name origin/master146147- Using your favorite editor, make your changes,148 `committing as you go`_.149- Include tests that cover any code changes you make. Make sure the150 test fails without your patch. Run the tests as described below.151- Push your commits to your fork on GitHub and152 `create a pull request`_. Link to the issue being addressed with153 ``fixes #123`` in the pull request.154155 .. code-block:: text156157 $ git push --set-upstream fork your-branch-name158159.. _committing as you go: https://dont-be-afraid-to-commit.readthedocs.io/en/latest/git/commandlinegit.html#commit-your-changes160.. _create a pull request: https://help.github.com/en/articles/creating-a-pull-request161162163Running the tests164~~~~~~~~~~~~~~~~~165166Run the basic test suite with pytest.167168.. code-block:: text169170 $ pytest171172This runs the tests for the current environment, which is usually173sufficient. CI will run the full suite when you submit your pull174request. You can run the full test suite with tox if you don't want to175wait.176177.. code-block:: text178179 $ tox180181182Running test coverage183~~~~~~~~~~~~~~~~~~~~~184185Generating a report of lines that do not have test coverage can indicate186where to start contributing. Run ``pytest`` using ``coverage`` and187generate a report.188189.. code-block:: text190191 $ pip install coverage192 $ coverage run -m pytest193 $ coverage html194195Open ``htmlcov/index.html`` in your browser to explore the report.196197Read more about `coverage <https://coverage.readthedocs.io>`__.198199200Building the docs201~~~~~~~~~~~~~~~~~202203Build the docs in the ``docs`` directory using Sphinx.204205.. code-block:: text206207 $ cd docs208 $ make html209210Open ``_build/html/index.html`` in your browser to view the docs.211212Read more about `Sphinx <https://www.sphinx-doc.org/en/stable/>`__.