How to contribute to Flask

Posted on Sat 13 May 2017 in Software Engineering

I want to contribute to Python Flask microframework. I read its CONTRIBUTING.rst file from GitHub. I encountered few issues because the documentation is not clear for me. It even sounds to be outdated.

I share here the steps that will allow you to later contribute to Flask. I hope they are more straightforward and clear than the official How to contribute to Flask.

Step 1. I cloned the repository:

git clone

The cloned repository is called by default flask. I renamed to something else:

mv flask/ contribute_to_flask/

I know it is all Ok to keep the name as it is, but because it contains a subfolder called also flask, I wanted to distinguish the parent from the child folder:

cd contribute_to_flask/ && ls
artwork           docs      Makefile     setup.cfg              tox.ini
AUTHORS           examples
CHANGES           flask     README       test-requirements.txt
CONTRIBUTING.rst  LICENSE   scripts      tests

Step 2. I create a virtual environment inside contribute_to_flask folder and installed pytest and tox:

virtualenv my_venv

The virtual environment can be anywhere except inside contribute_to_flask/flask/ folder. This is in order to avoid Flask to think that it's installed rather than running locally. The test doesn't expect the project to appear to be installed1. I then activated the virtual environment:

cd my_venv
source bin/activate

I installed pytest to perform unit testing:

pip install pytest

I also installed tox in order to run all tests against multiple combinations Python versions and dependency versions

pip install tox

Step 3. I installed Flask as an editable package using the current source:

pip install --editable .

Step 4. I installed the test requirements:

pip install -r test-requirements.txt

The -r option is there to specify that pip must is going to install requirements usually listed in a plain text file.

Step 5. I run the tests:

pytest tests/

I got this output: 332 passed, 10 skipped in 32.86 seconds.

Step 6. I installed and run the test coverage:

pip install pytest-cov

The test coverage:

pytest --cov=flask tests/

It seems there is a good code coverage:

----------- coverage: platform linux, python 3.5.2-final-0 -----------
Name                    Stmts   Miss  Cover
flask/          17      0   100%
flask/           4      4     0%
flask/           52     28    46%
flask/              580     42    93%
flask/       159     36    77%
flask/              275     85    69%
flask/            90      2    98%
flask/              151     23    85%
flask/      91     12    87%
flask/ext/       7      0   100%
flask/           61      3    95%
flask/           26      0   100%
flask/          324     40    88%
flask/              89     13    85%
flask/           46      1    98%
flask/         143      8    94%
flask/           29      2    93%
flask/        82      3    96%
flask/           65      3    95%
flask/             41      1    98%
flask/          74      4    95%
TOTAL                    2406    310    87%

That is it. Now I am ready to go further.

1 test_main_module_paths fails on RHEL and Ubuntu when using Amazon EC2, #1879