Skip to content
Myr

update contributing guide

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

authored by David Lord · committed by David Lord · parent 3ee366a · Browse files · 1 file+55 added−73 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+55 added−73 removed

  • other:+55 added−73 removed

1 file+55 added−73 removed

modified:CONTRIBUTING.rst+55 added-73 removed
5 unmodified lines
67Support questions8-----------------910Please, don't use the issue tracker for this. Use one of the following11resources for questions about your own code:10Please, don't use the issue tracker for this. The issue tracker is a11tool to address bugs and feature requests in Flask itself. Use one of12the following resources for questions about using Flask or issues with13your own code:1415- The ``#get-help`` channel on our Discord chat:16 https://discord.gg/t6rrQZH1516 - The IRC channel ``#pocoo`` on FreeNode is linked to Discord, but17 Discord is preferred.1817- The mailing list flask@python.org for long term discussion or larger18 issues.19- Ask on `Stack Overflow`_. Search with Google first using:22 ``site:stackoverflow.com flask {search term, exception message, etc.}``20 ``site:stackoverflow.com python flask {search term, exception message, etc.}``2122.. _Stack Overflow: https://stackoverflow.com/questions/tagged/flask?sort=linked232425Reporting issues26----------------2728Include the following information in your post:2930- 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, Flask, and Werkzeug versions. If possible, check37 if this issue is already fixed in the repository.37 if this issue is already fixed in the latest releases or the latest38 code in the repository.3940.. _minimal reproducible example: https://stackoverflow.com/help/minimal-reproducible-example414243Submitting patches44------------------4545- Use `Black`_ to autoformat your code. This should be done for you as46 a Git `pre-commit`_ hook, set up below. You may also wish to use47 Black's `Editor integration`_.48- Include tests if your patch is supposed to solve a bug, and explain49 clearly under which circumstances the bug happens. Make sure the50 test fails without your patch.51- Include a string like "Fixes #123" in your commit message (where 12352 is the issue you fixed). See `Closing issues using keywords53 <https://help.github.com/articles/creating-a-pull-request/>`__.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.5152Include the following in your patch:5354- 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.6465.. _Black: https://black.readthedocs.io66.. _pre-commit: https://pre-commit.com676869First time setup70~~~~~~~~~~~~~~~~7172- Download and install the `latest version of git`_.
5 unmodified lines
78 $ git config --global user.email 'your email'7980- Make sure you have a `GitHub account`_.81- Fork Flask to your GitHub account by clicking the `Fork`_ button.69- `Clone`_ your GitHub fork locally.82- `Clone`_ the main repository locally.8384 .. code-block:: text8573 $ git clone https://github.com/{username}/flask86 $ git clone https://github.com/pallets/flask87 $ cd flask8876- Add the main repository as a remote to update later.89- Add your fork as a remote to push your work to. Replace90 ``{username}`` with your username. This names the remote "fork", the91 default Pallets remote is "origin".9293 .. code-block:: text9480 $ git remote add pallets https://github.com/pallets/flask81 $ git fetch pallets95 git remote add fork https://github.com/{username}/flask9697- Create a virtualenv.9899 .. code-block:: text
18 unmodified lines
118 .. code-block:: text119120 $ pre-commit install121108.. _GitHub account: https://github.com/join122.. _latest version of git: https://git-scm.com/downloads123.. _username: https://help.github.com/en/articles/setting-your-username-in-git124.. _email: https://help.github.com/en/articles/setting-your-commit-email-address-in-git125.. _GitHub account: https://github.com/join126.. _Fork: https://github.com/pallets/flask/fork127.. _Clone: https://help.github.com/en/articles/fork-a-repo#step-2-create-a-local-clone-of-your-fork114.. _pre-commit framework: https://pre-commit.com/#install128129130Start coding131~~~~~~~~~~~~
3 unmodified lines
135 latest ".x" branch.136137 .. code-block:: text138139 $ git fetch origin126 $ git checkout -b your-branch-name origin/1.0.x140 $ git checkout -b your-branch-name origin/1.1.x141142 If you're submitting a feature addition or change, branch off of the143 "master" branch.144145 .. code-block:: text146147 $ git fetch origin148 $ git checkout -b your-branch-name origin/master149150- Using your favorite editor, make your changes,151 `committing as you go`_.152- Include tests that cover any code changes you make. Make sure the138 test fails without your patch.139 `Run the tests <contributing-testsuite_>`_.140- Push your commits to GitHub and `create a pull request`_.153 test fails without your patch. Run the tests as described below.154- Push your commits to your fork on GitHub and155 `create a pull request`_. Link to the issue being addressed with156 ``fixes #123`` in the pull request.157158 .. code-block:: text159144 $ git push --set-upstream origin your-branch-name160 $ git push --set-upstream fork your-branch-name161162.. _committing as you go: https://dont-be-afraid-to-commit.readthedocs.io/en/latest/git/commandlinegit.html#commit-your-changes147.. _Black: https://black.readthedocs.io148.. _Editor integration: https://black.readthedocs.io/en/stable/editor_integration.html149.. _pre-commit: https://pre-commit.com163.. _create a pull request: https://help.github.com/en/articles/creating-a-pull-request164165153.. _contributing-testsuite: #running-the-tests154166Running the tests167~~~~~~~~~~~~~~~~~168169Run the basic test suite with pytest.
1 unmodified line
171.. code-block:: text172173 $ pytest174164This only runs the tests for the current environment. Whether this is165relevant depends on which part of Flask you're working on. CI will run166the full suite when you submit your pull request.175This runs the tests for the current environment, which is usually176sufficient. CI will run the full suite when you submit your pull177request. You can run the full test suite with tox if you don't want to178wait.179168The full test suite takes a long time to run because it tests multiple169combinations of Python and dependencies. If you don't have a Python170version installed, it will be skipped with a warning message at the end.171180.. code-block:: text181182 $ tox183
2 unmodified lines
186~~~~~~~~~~~~~~~~~~~~~187188Generating a report of lines that do not have test coverage can indicate189where to start contributing. Run ``pytest`` using ``coverage`` and182generate a report on the terminal and as an interactive HTML document.190generate a report.191192.. code-block:: text193194 $ pip install coverage195 $ coverage run -m pytest187 $ coverage report188 $ coverage html # then open htmlcov/index.html196 $ coverage html197190Read more about `coverage <https://coverage.readthedocs.io>`_.198Open ``htmlcov/index.html`` in your browser to explore the report.199192Running the full test suite with ``tox`` will combine the coverage reports193from all runs.200Read more about `coverage <https://coverage.readthedocs.io>`__.201202203Building the docs204~~~~~~~~~~~~~~~~~
6 unmodified lines
211 $ make html212213Open ``_build/html/index.html`` in your browser to view the docs.214208Read more about `Sphinx <https://www.sphinx-doc.org/en/master/>`_.209210211Caution: zero-padded file modes212-------------------------------213214This repository contains several zero-padded file modes that may cause215issues when pushing this repository to Git hosts other than GitHub.216Fixing this is destructive to the commit history, so we suggest ignoring217these warnings. If it fails to push and you're using a self-hosted Git218service like GitLab, you can turn off repository checks in the admin219panel.220221These files can also cause issues while cloning if you have222``fsckObjects`` enabled with either of the following in your git config.223224.. code-block::225226 [fetch]227 fsckObjects = true228229 [receive]230 fsckObjects = true231232The only solution is to set both of the above to ``false``, clone, and233then set them back to ``true`` after.215Read more about `Sphinx <https://www.sphinx-doc.org/en/stable/>`__.