CONTRIBUTING.rst
This file
Path
CONTRIBUTING.rst
238 lines · 7.8 KiB
Last changed by
Merge branch '2.3.x'David Lordbefore adoption15a0d4a
History of this fileTake it
The walk stopped after 200 commits: lines older than 0ae0f59 point at it.
Merge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 1–18why, one step back1How to contribute to Flask2==========================34Thank you for considering contributing to Flask!567Support questions8-----------------910Please don't use the issue tracker for this. The issue tracker is a tool11to address bugs and feature requests in Flask itself. Use one of the12following resources for questions about using Flask or issues with your13own code:1415- The ``#questions`` channel on our Discord chat:16 https://discord.gg/pallets17- Ask on `Stack Overflow`_. Search with Google first using:18 ``site:stackoverflow.com flask {search term, exception message, etc.}``Merge remote-tracking branch 'origin/2.1.x'David Lordbefore adoptiona25d234
lines 19–20why, one step back19- Ask on our `GitHub Discussions`_ for long term discussion or larger20 questions.Merge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 21–69why, one step back2122.. _Stack Overflow: https://stackoverflow.com/questions/tagged/flask?tab=Frequent23.. _GitHub Discussions: https://github.com/pallets/flask/discussions242526Reporting issues27----------------2829Include the following information in your post:3031- Describe what you expected to happen.32- If possible, include a `minimal reproducible example`_ to help us33 identify the issue. This also helps check that the issue is not with34 your own code.35- Describe what actually happened. Include the full traceback if there36 was an exception.37- List your Python and Flask versions. If possible, check if this38 issue is already fixed in the latest releases or the latest code in39 the repository.4041.. _minimal reproducible example: https://stackoverflow.com/help/minimal-reproducible-example424344Submitting patches45------------------4647If there is not an open issue for what you want to submit, prefer48opening one for discussion before working on a PR. You can work on any49issue that doesn't have an open PR linked to it or a maintainer assigned50to it. These show up in the sidebar. No need to ask if you can work on51an issue that interests you.5253Include the following in your patch:5455- Use `Black`_ to format your code. This and other tools will run56 automatically if you install `pre-commit`_ using the instructions57 below.58- Include tests if your patch adds or changes code. Make sure the test59 fails without your patch.60- Update any relevant docs pages and docstrings. Docs pages and61 docstrings should be wrapped at 72 characters.62- Add an entry in ``CHANGES.rst``. Use the same style as other63 entries. Also include ``.. versionchanged::`` inline changelogs in64 relevant docstrings.6566.. _Black: https://black.readthedocs.io67.. _pre-commit: https://pre-commit.com6869Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d
lines 70–71why, one step back70First time setup using GitHub Codespaces71~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Merge branch '2.0.x'David Lordbefore adoption0ae0f59
line 72why, one step back72Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d
lines 73–92why, one step back73`GitHub Codespaces`_ creates a development environment that is already set up for the74project. By default it opens in Visual Studio Code for the Web, but this can75be changed in your GitHub profile settings to use Visual Studio Code or JetBrains76PyCharm on your local computer.7778- Make sure you have a `GitHub account`_.79- From the project's repository page, click the green "Code" button and then "Create80 codespace on main".81- The codespace will be set up, then Visual Studio Code will open. However, you'll82 need to wait a bit longer for the Python extension to be installed. You'll know it's83 ready when the terminal at the bottom shows that the virtualenv was activated.84- Check out a branch and `start coding`_.8586.. _GitHub Codespaces: https://docs.github.com/en/codespaces87.. _devcontainer: https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers8889First time setup in your local environment90~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~9192- Make sure you have a `GitHub account`_.Merge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 93–101why, one step back93- Download and install the `latest version of git`_.94- Configure git with your `username`_ and `email`_.9596 .. code-block:: text9798 $ git config --global user.name 'your name'99 $ git config --global user.email 'your email'100101- Fork Flask to your GitHub account by clicking the `Fork`_ button.Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d
lines 102–103why, one step back102- `Clone`_ your fork locally, replacing ``your-username`` in the command below with103 your actual username.Merge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 104–106why, one step back104105 .. code-block:: text106Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d
line 107why, one step back107 $ git clone https://github.com/your-username/flaskMerge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 108–109why, one step back108 $ cd flask109Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d
line 110why, one step back110- Create a virtualenv. Use the latest version of Python.Merge branch '2.0.x'David Lordbefore adoption0ae0f59
line 111why, one step back111Merge remote-tracking branch 'origin/2.1.x'David Lordbefore adoptiona25d234
line 112why, one step back112 - Linux/macOSMerge branch '2.0.x'David Lordbefore adoption0ae0f59
line 113why, one step back113Merge remote-tracking branch 'origin/2.1.x'David Lordbefore adoptiona25d234
line 114why, one step back114 .. code-block:: textMerge branch '2.0.x'David Lordbefore adoption0ae0f59
line 115why, one step back115Merge pull request #4947 from pallets/pyprojectDavid Lordbefore adoption78b42b9
lines 116–117why, one step back116 $ python3 -m venv .venv117 $ . .venv/bin/activateMerge branch '2.0.x'David Lordbefore adoption0ae0f59
line 118why, one step back118Merge remote-tracking branch 'origin/2.1.x'David Lordbefore adoptiona25d234
line 119why, one step back119 - WindowsMerge branch '2.0.x'David Lordbefore adoption0ae0f59
line 120why, one step back120Merge remote-tracking branch 'origin/2.1.x'David Lordbefore adoptiona25d234
line 121why, one step back121 .. code-block:: textMerge branch '2.0.x'David Lordbefore adoption0ae0f59
line 122why, one step back122Merge pull request #4947 from pallets/pyprojectDavid Lordbefore adoption78b42b9
line 123why, one step back123 > py -3 -m venv .venvfix typoDavid Lordbefore adoption9a4d370
line 124why, one step back124 > .venv\Scripts\activateMerge branch '2.0.x'David Lordbefore adoption0ae0f59
line 125why, one step back125Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d
line 126why, one step back126- Install the development dependencies, then install Flask in editable mode.Merge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 127–129why, one step back127128 .. code-block:: text129Merge branch '2.3.x'David Lordbefore adoption15a0d4a
line 130why, one step back130 $ python -m pip install -U pipMerge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 131–136why, one step back131 $ pip install -r requirements/dev.txt && pip install -e .132133- Install the pre-commit hooks.134135 .. code-block:: text136Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d
line 137why, one step back137 $ pre-commit install --install-hooksMerge branch '2.0.x'David Lordbefore adoption0ae0f59
line 138why, one step back138Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d
line 139why, one step back139.. _GitHub account: https://github.com/joinMerge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 140–145why, one step back140.. _latest version of git: https://git-scm.com/downloads141.. _username: https://docs.github.com/en/github/using-git/setting-your-username-in-git142.. _email: https://docs.github.com/en/github/setting-up-and-managing-your-github-user-account/setting-your-commit-email-address143.. _Fork: https://github.com/pallets/flask/fork144.. _Clone: https://docs.github.com/en/github/getting-started-with-github/fork-a-repo#step-2-create-a-local-clone-of-your-fork145Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d
line 146why, one step back146.. _start coding:Merge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 147–150why, one step back147148Start coding149~~~~~~~~~~~~150Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d
lines 151–152why, one step back151- Create a branch to identify the issue you would like to work on. If you're152 submitting a bug or documentation fix, branch off of the latest ".x" branch.Merge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 153–158why, one step back153154 .. code-block:: text155156 $ git fetch origin157 $ git checkout -b your-branch-name origin/2.0.x158Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d
line 159why, one step back159 If you're submitting a feature addition or change, branch off of the "main" branch.Merge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 160–165why, one step back160161 .. code-block:: text162163 $ git fetch origin164 $ git checkout -b your-branch-name origin/main165Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d
line 166why, one step back166- Using your favorite editor, make your changes, `committing as you go`_.Merge branch '2.0.x'David Lordbefore adoption0ae0f59
line 167why, one step back167Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d
lines 168–175why, one step back168 - If you are in a codespace, you will be prompted to `create a fork`_ the first169 time you make a commit. Enter ``Y`` to continue.170171- Include tests that cover any code changes you make. Make sure the test fails without172 your patch. Run the tests as described below.173- Push your commits to your fork on GitHub and `create a pull request`_. Link to the174 issue being addressed with ``fixes #123`` in the pull request description.175Merge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 176–177why, one step back176 .. code-block:: text177Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d
line 178why, one step back178 $ git push --set-upstream origin your-branch-nameMerge branch '2.0.x'David Lordbefore adoption0ae0f59
line 179why, one step back179Merge branch '2.2.x'David Lordbefore adoption7464e17
line 180why, one step back180.. _committing as you go: https://afraid-to-commit.readthedocs.io/en/latest/git/commandlinegit.html#commit-your-changesAdd a devcontainer configuration (#4969)emisargentbefore adoption182ce3d
line 181why, one step back181.. _create a fork: https://docs.github.com/en/codespaces/developing-in-codespaces/using-source-control-in-your-codespace#about-automatic-forkingMerge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 182–183why, one step back182.. _create a pull request: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request183Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d
line 184why, one step back184.. _Running the tests:Merge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 185–210why, one step back185186Running the tests187~~~~~~~~~~~~~~~~~188189Run the basic test suite with pytest.190191.. code-block:: text192193 $ pytest194195This runs the tests for the current environment, which is usually196sufficient. CI will run the full suite when you submit your pull197request. You can run the full test suite with tox if you don't want to198wait.199200.. code-block:: text201202 $ tox203204205Running test coverage206~~~~~~~~~~~~~~~~~~~~~207208Generating a report of lines that do not have test coverage can indicate209where to start contributing. Run ``pytest`` using ``coverage`` and210generate a report.Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d
lines 211–213why, one step back211212If you are using GitHub Codespaces, ``coverage`` is already installed213so you can skip the installation command.Merge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 214–238why, one step back214215.. code-block:: text216217 $ pip install coverage218 $ coverage run -m pytest219 $ coverage html220221Open ``htmlcov/index.html`` in your browser to explore the report.222223Read more about `coverage <https://coverage.readthedocs.io>`__.224225226Building the docs227~~~~~~~~~~~~~~~~~228229Build the docs in the ``docs`` directory using Sphinx.230231.. code-block:: text232233 $ cd docs234 $ make html235236Open ``_build/html/index.html`` in your browser to view the docs.237238Read more about `Sphinx <https://www.sphinx-doc.org/en/stable/>`__.