Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Run mypy as part of the lint script #8633

Merged
merged 7 commits into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,35 @@ run-time:
./scripts-dev/lint.sh path/to/file1.py path/to/file2.py path/to/folder
```

You can also provided the `-d` option, which will lint the files that have been
You can also provide the `-d` option, which will lint the files that have been
changed since the last git commit. This will often be significantly faster than
linting the whole codebase.

Another option is to only run types checks, with `mypy`, in a fresh virtual env:
clokep marked this conversation as resolved.
Show resolved Hide resolved

```
# Create the virtual env, the name of this venv must be 'testenv'
python -m venv testenv

# activate the virtual env for the current shell and install tox
source testenv/bin/activate
pip install tox

# install dependencies and run tests
tox -e mypy
```

or quicker, if you just want to run mypy appart from the other tests:

```
# After creating and activating a venv for the current shell
# install mypy and the dependencies
pip install -e .[mypy]

# run tests
mypy
```

Before pushing new changes, ensure they don't produce linting errors. Commit any
files that were corrected.

Expand Down
1 change: 1 addition & 0 deletions changelog.d/8633.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add instructions to run types checks in an isolated venv.
clokep marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions scripts-dev/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,4 @@ isort "${files[@]}"
python3 -m black "${files[@]}"
./scripts-dev/config-lint.sh
flake8 "${files[@]}"
mypy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I think running this over $files[@] doesn't make sense until we support mypy in all of our files.