Skip to content
Myr

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 file

Take 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 back
1How to contribute to Flask
2==========================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 back
19- Ask on our `GitHub Discussions`_ for long term discussion or larger
20 questions.

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

lines 21–69why, one step back
21
22.. _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.com6869

Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d

lines 70–71why, one step back
70First time setup using GitHub Codespaces
71~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

line 72why, one step back
72

Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d

lines 73–92why, one step back
73`GitHub Codespaces`_ creates a development environment that is already set up for the
74project. 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 back
93- 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 back
102- `Clone`_ your fork locally, replacing ``your-username`` in the command below with
103 your actual username.

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

lines 104–106why, one step back
104
105 .. code-block:: text106

Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d

line 107why, one step back
107 $ git clone https://github.com/your-username/flask

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

lines 108–109why, one step back
108 $ cd flask
109

Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d

line 110why, one step back
110- Create a virtualenv. Use the latest version of Python.

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

line 111why, one step back
111

Merge remote-tracking branch 'origin/2.1.x'David Lordbefore adoptiona25d234

line 112why, one step back
112 - Linux/macOS

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

line 113why, one step back
113

Merge remote-tracking branch 'origin/2.1.x'David Lordbefore adoptiona25d234

line 114why, one step back
114 .. code-block:: text

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

line 115why, one step back
115

Merge pull request #4947 from pallets/pyprojectDavid Lordbefore adoption78b42b9

lines 116–117why, one step back
116 $ python3 -m venv .venv
117 $ . .venv/bin/activate

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

line 118why, one step back
118

Merge remote-tracking branch 'origin/2.1.x'David Lordbefore adoptiona25d234

line 119why, one step back
119 - Windows

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

line 120why, one step back
120

Merge remote-tracking branch 'origin/2.1.x'David Lordbefore adoptiona25d234

line 121why, one step back
121 .. code-block:: text

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

line 122why, one step back
122

Merge pull request #4947 from pallets/pyprojectDavid Lordbefore adoption78b42b9

line 123why, one step back
123 > py -3 -m venv .venv

fix typoDavid Lordbefore adoption9a4d370

line 124why, one step back
124 > .venv\Scripts\activate

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

line 125why, one step back
125

Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d

line 126why, one step back
126- Install the development dependencies, then install Flask in editable mode.

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

lines 127–129why, one step back
127
128 .. code-block:: text129

Merge branch '2.3.x'David Lordbefore adoption15a0d4a

line 130why, one step back
130 $ python -m pip install -U pip

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

lines 131–136why, one step back
131 $ pip install -r requirements/dev.txt && pip install -e .
132133- Install the pre-commit hooks.134135 .. code-block:: text136

Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d

line 137why, one step back
137 $ pre-commit install --install-hooks

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

line 138why, one step back
138

Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d

line 139why, one step back
139.. _GitHub account: https://github.com/join

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

lines 140–145why, one step back
140.. _latest version of git: https://git-scm.com/downloads
141.. _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-fork145

Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d

line 146why, one step back
146.. _start coding:

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

lines 147–150why, one step back
147
148Start coding149~~~~~~~~~~~~150

Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d

lines 151–152why, one step back
151- Create a branch to identify the issue you would like to work on. If you're
152 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 back
153
154 .. code-block:: text155156 $ git fetch origin157 $ git checkout -b your-branch-name origin/2.0.x158

Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d

line 159why, one step back
159 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 back
160
161 .. code-block:: text162163 $ git fetch origin164 $ git checkout -b your-branch-name origin/main165

Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d

line 166why, one step back
166- Using your favorite editor, make your changes, `committing as you go`_.

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

line 167why, one step back
167

Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d

lines 168–175why, one step back
168 - If you are in a codespace, you will be prompted to `create a fork`_ the first
169 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.175

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

lines 176–177why, one step back
176 .. code-block:: text
177

Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d

line 178why, one step back
178 $ git push --set-upstream origin your-branch-name

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

line 179why, one step back
179

Merge branch '2.2.x'David Lordbefore adoption7464e17

line 180why, one step back
180.. _committing as you go: https://afraid-to-commit.readthedocs.io/en/latest/git/commandlinegit.html#commit-your-changes

Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d

line 181why, one step back
181.. _create a fork: https://docs.github.com/en/codespaces/developing-in-codespaces/using-source-control-in-your-codespace#about-automatic-forking

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

lines 182–183why, one step back
182.. _create a pull request: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request
183

Add a devcontainer configuration (#4969)emisargentbefore adoption182ce3d

line 184why, one step back
184.. _Running the tests:

Merge branch '2.0.x'David Lordbefore adoption0ae0f59

lines 185–210why, one step back
185
186Running 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 back
211
212If 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 back
214
215.. 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/>`__.