Skip to content
Myr

CONTRIBUTING.rst

This file

Path

CONTRIBUTING.rst

196 lines · 6.4 KiB

Last changed by

Merge pull request #3213 from jab/contributingJoshua Bronsonbefore adoptionfe41c6c

History of this file

Take it

1How to contribute to Flask2==========================34Thank you for considering contributing to Flask!56Support questions7-----------------89Please, don't use the issue tracker for this. Use one of the following10resources for questions about your own code:1112* The ``#get-help`` channel on our Discord chat: https://discord.gg/t6rrQZH1314  * The IRC channel ``#pocoo`` on FreeNode is linked to Discord, but15    Discord is preferred.1617* The mailing list flask@python.org for long term discussion or larger issues.18* Ask on `Stack Overflow`_. Search with Google first using:19  ``site:stackoverflow.com flask {search term, exception message, etc.}``2021.. _Stack Overflow: https://stackoverflow.com/questions/tagged/flask?sort=linked2223Reporting issues24----------------2526- Describe what you expected to happen.27- If possible, include a `minimal, complete, and verifiable example`_ to help28  us identify the issue. This also helps check that the issue is not with your29  own code.30- Describe what actually happened. Include the full traceback if there was an31  exception.32- List your Python, Flask, and Werkzeug versions. If possible, check if this33  issue is already fixed in the repository.3435.. _minimal, complete, and verifiable example: https://stackoverflow.com/help/mcve3637Submitting patches38------------------3940- Use `Black`_ to autoformat your code. This should be done for you as a41  git `pre-commit`_ hook, which gets installed when you run ``pip install -e .[dev]``.42  You may also wish to use Black's `Editor integration`_.43- Include tests if your patch is supposed to solve a bug, and explain44  clearly under which circumstances the bug happens. Make sure the test fails45  without your patch.4647First time setup48~~~~~~~~~~~~~~~~4950- Download and install the `latest version of git`_.51- Configure git with your `username`_ and `email`_::5253        git config --global user.name 'your name'54        git config --global user.email 'your email'5556- Make sure you have a `GitHub account`_.57- Fork Flask to your GitHub account by clicking the `Fork`_ button.58- `Clone`_ your GitHub fork locally::5960        git clone https://github.com/{username}/flask61        cd flask6263- Add the main repository as a remote to update later::6465        git remote add pallets https://github.com/pallets/flask66        git fetch pallets6768- Create a virtualenv::6970        python3 -m venv env71        . env/bin/activate72        # or "env\Scripts\activate" on Windows7374- Install Flask in editable mode with development dependencies::7576        pip install -e ".[dev]"7778.. _GitHub account: https://github.com/join79.. _latest version of git: https://git-scm.com/downloads80.. _username: https://help.github.com/articles/setting-your-username-in-git/81.. _email: https://help.github.com/articles/setting-your-email-in-git/82.. _Fork: https://github.com/pallets/flask/fork83.. _Clone: https://help.github.com/articles/fork-a-repo/#step-2-create-a-local-clone-of-your-fork8485Start coding86~~~~~~~~~~~~8788-   Create a branch to identify the issue you would like to work on. If89    you're submitting a bug or documentation fix, branch off of the90    latest ".x" branch::9192        git checkout -b your-branch-name origin/1.0.x9394    If you're submitting a feature addition or change, branch off of the95    "master" branch::9697        git checkout -b your-branch-name origin/master9899- Using your favorite editor, make your changes, `committing as you go`_.100- Include tests that cover any code changes you make. Make sure the test fails101  without your patch. `Run the tests. <contributing-testsuite_>`_.102- Push your commits to GitHub and `create a pull request`_ by using::103104        git push --set-upstream origin your-branch-name105106- Celebrate 🎉107108.. _committing as you go: https://dont-be-afraid-to-commit.readthedocs.io/en/latest/git/commandlinegit.html#commit-your-changes109.. _Black: https://black.readthedocs.io110.. _Editor integration: https://black.readthedocs.io/en/stable/editor_integration.html111.. _pre-commit: https://pre-commit.com112.. _create a pull request: https://help.github.com/articles/creating-a-pull-request/113114.. _contributing-testsuite:115116Running the tests117~~~~~~~~~~~~~~~~~118119Run the basic test suite with::120121    pytest122123This only runs the tests for the current environment. Whether this is relevant124depends on which part of Flask you're working on. Travis-CI will run the full125suite when you submit your pull request.126127The full test suite takes a long time to run because it tests multiple128combinations of Python and dependencies. You need to have Python 2.7, 3.4,1293.5 3.6, and PyPy 2.7 installed to run all of the environments. Then run::130131    tox132133Running test coverage134~~~~~~~~~~~~~~~~~~~~~135136Generating a report of lines that do not have test coverage can indicate137where to start contributing. Run ``pytest`` using ``coverage`` and generate a138report on the terminal and as an interactive HTML document::139140    coverage run -m pytest141    coverage report142    coverage html143    # then open htmlcov/index.html144145Read more about `coverage <https://coverage.readthedocs.io>`_.146147Running the full test suite with ``tox`` will combine the coverage reports148from all runs.149150151Building the docs152~~~~~~~~~~~~~~~~~153154Build the docs in the ``docs`` directory using Sphinx::155156    cd docs157    make html158159Open ``_build/html/index.html`` in your browser to view the docs.160161Read more about `Sphinx <https://www.sphinx-doc.org>`_.162163164make targets165~~~~~~~~~~~~166167Flask provides a ``Makefile`` with various shortcuts. They will ensure that168all dependencies are installed.169170- ``make test`` runs the basic test suite with ``pytest``171- ``make cov`` runs the basic test suite with ``coverage``172- ``make test-all`` runs the full test suite with ``tox``173- ``make docs`` builds the HTML documentation174175Caution: zero-padded file modes176-------------------------------177178This repository contains several zero-padded file modes that may cause issues179when pushing this repository to git hosts other than GitHub. Fixing this is180destructive to the commit history, so we suggest ignoring these warnings. If it181fails to push and you're using a self-hosted git service like GitLab, you can182turn off repository checks in the admin panel.183184These files can also cause issues while cloning. If you have ::185186    [fetch]187    fsckobjects = true188189or ::190191    [receive]192    fsckObjects = true193194set in your git configuration file, cloning this repository will fail. The only195solution is to set both of the above settings to false while cloning, and then196setting them back to true after the cloning is finished.