diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eafefe346d01..c51e812c6492 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,48 +17,64 @@ articulated in the [Python Community Code of Conduct](https://www.python.org/psf ### Setup -Run the following: +#### (1) Clone the mypy repository and enter into it ``` -# Clone the mypy repository git clone https://github.com/python/mypy.git - -# Enter the repository cd mypy +``` -# Create then activate a virtual environment +#### (2) Create then activate a virtual environment +``` +# On Windows, the commands may be slightly different. For more details, see +# https://docs.python.org/3/library/venv.html#creating-virtual-environments python3 -m venv venv source venv/bin/activate +``` -# Install the test requirements and the project +#### (3) Install the test requirements and the project +``` python3 -m pip install -r test-requirements.txt python3 -m pip install -e . -hash -r +hash -r # This resets shell PATH cache, not necessary on Windows ``` ### Running tests -Once setup, you should be able to run tests: -``` -python3 runtests.py -``` +Running the full test suite can take a while, and usually isn't necessary when +preparing a PR. Once you file a PR, the full test suite will run on GitHub. +You'll then be able to see any test failures, and make any necessary changes to +your PR. -To use mypy to check mypy's own code, run: +However, if you wish to do so, you can run the full test suite +like this: ``` -python3 runtests.py self -# or equivalently: -python3 -m mypy --config-file mypy_self_check.ini -p mypy +python3 runtests.py ``` -You can also use `tox` to run tests, for instance: +You can also use `tox` to run tests (`tox` handles setting up the test environment for you): ``` tox -e py ``` -The easiest way to run a single test is: +Some useful commands for running specific tests include: ``` +# Use mypy to check mypy's own code +python3 runtests.py self +# or equivalently: +python3 -m mypy --config-file mypy_self_check.ini -p mypy + +# Run a single test from the test suite pytest -n0 -k 'test_name' + +# Run all test cases in the "test-data/unit/check-dataclasses.test" file +pytest mypy/test/testcheck.py::TypeCheckSuite::check-dataclasses.test + +# Run the linter +flake8 ``` -There's more useful information on writing and running tests [here](test-data/unit/README.md) + +For an in-depth guide on running and writing tests, +see [the README in the test-data directory](test-data/unit/README.md). ## First time contributors