Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to mypy part0 #6470

Merged
merged 27 commits into from
Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4900944
remove pytype and setup mypy
m-vdb Aug 21, 2020
661ab0b
fix wrong type annotations
m-vdb Aug 21, 2020
0d35a59
update mypy config to ignore current errors
m-vdb Aug 26, 2020
684df65
Merge branch 'master' into switch-to-mypy
m-vdb Aug 26, 2020
ee42c23
Merge branch 'master' into switch-to-mypy
m-vdb Aug 31, 2020
1b553ab
Merge branch 'master' into switch-to-mypy
m-vdb Sep 2, 2020
17f125d
keep pytype around during transition
m-vdb Sep 3, 2020
199f7b9
Merge branch 'master' into switch-to-mypy
m-vdb Sep 3, 2020
c559a9f
Merge branch 'master' into switch-to-mypy
m-vdb Sep 28, 2020
077d5df
Merge branch 'master' into switch-to-mypy
m-vdb Oct 12, 2020
cef6a96
fix typing annotation
m-vdb Oct 12, 2020
85c785d
disable error codes one by one
m-vdb Oct 12, 2020
e232d1a
remove pytype completely
m-vdb Oct 14, 2020
cbb6182
Update CONTRIBUTING.md to refer to `mypy`
m-vdb Oct 14, 2020
3d0bf71
Fix type hint in DIET classifier
m-vdb Oct 14, 2020
5ffd764
Fix type hint in TED policy
m-vdb Oct 14, 2020
059dd54
explain why we ignore missing imports
m-vdb Oct 14, 2020
f1f1c01
Merge branch 'master' into switch-to-mypy
m-vdb Oct 14, 2020
7fa00f4
remove pytype annotations
m-vdb Oct 14, 2020
a7cb682
remove pytype related comments + code
m-vdb Oct 14, 2020
c6a3ec3
add changelog fragment
m-vdb Oct 14, 2020
a36d598
Revert "remove pytype annotations"
m-vdb Oct 16, 2020
8980e04
remove pytype annotations
m-vdb Oct 16, 2020
90597cc
Merge branch 'master' into switch-to-mypy
m-vdb Oct 16, 2020
4067a4b
remove more pytype comments
m-vdb Oct 19, 2020
df3b79f
Merge branch 'master' into switch-to-mypy
m-vdb Oct 19, 2020
7114fb8
remove unnecessary new lines
m-vdb Oct 19, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ venv
.ipynb_checkpoints
.ruby-version
.tox
.pytype
.mypy_cache/
dist/
pip-wheel-metadata
server/
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ If your PR is greater than 500 lines, please consider splitting it into multiple

#### Code style

To ensure a standardized code style we recommend using formatter black. To ensure our type annotations are correct we also suggest using the type checker pytype.
To ensure a standardized code style we recommend using formatter black. To ensure our type annotations are correct we also suggest using the type checker `mypy`.

#### Formatting and Type Checking

If you want to automatically format your code on every commit, you can use pre-commit. Just install it via `pip install pre-commit` and execute `pre-commit install` in the root folder. This will add a hook to the repository, which reformats files on every commit.

If you want to set it up manually, install black via `pip install -r requirements-dev.txt.` To reformat files execute `make formatter`.

If you want to check types on the codebase, install pytype using `pip install -r requirements-dev.txt`. To check the types execute `make types`.
If you want to check types on the codebase, install `mypy` using `pip install -r requirements-dev.txt`. To check the types execute `make types`.
m-vdb marked this conversation as resolved.
Show resolved Hide resolved

The CI/CD tests that we run can be found in the [continous-integration.yml](https://github.com/RasaHQ/rasa/blob/master/.github/workflows/continous-integration.yml) file.

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ help:
@echo " lint"
@echo " Lint code with flake8, and check if black formatter should be applied."
@echo " types"
@echo " Check for type errors using pytype."
@echo " Check for type errors using mypy."
@echo " prepare-tests-ubuntu"
@echo " Install system requirements for running tests on Ubuntu and Debian based systems."
@echo " prepare-tests-macos"
Expand All @@ -37,7 +37,7 @@ clean:
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
rm -rf build/
rm -rf .pytype/
rm -rf .mypy_cache/
rm -rf dist/
rm -rf docs/build
rm -rf docs/.docusaurus
Expand Down Expand Up @@ -68,7 +68,7 @@ lint:
poetry run black --check rasa tests

types:
poetry run pytype --keep-going rasa -j 16
poetry run mypy rasa

prepare-tests-files:
poetry install -E spacy
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ make formatter

#### Type Checking

If you want to check types on the codebase, install `pytype` using `poetry install`.
If you want to check types on the codebase, install `mypy` using `poetry install`.
m-vdb marked this conversation as resolved.
Show resolved Hide resolved
To check the types execute
```
make types
Expand Down
276 changes: 132 additions & 144 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ fakeredis = "^1.4.0"
mongomock = "^3.18.0"
black = "^19.10b0"
flake8 = "^3.8.3"
pytype = "^2020.6.1"
google-cloud-storage = "^1.29.0"
azure-storage-blob = "<12.4.0"
coveralls = "^2.0.0"
towncrier = "^19.2.0"
toml = "^0.10.0"
pep440-version-utils = "^0.3.0"
pydoc-markdown = "3.3.0.post1"
mypy = "^0.782"

[tool.poetry.extras]
spacy = [ "spacy",]
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/policies/ted_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def __init__(
self.metrics_to_log += ["loss", "acc"]

# set up tf layers
self._tf_layers: Dict[Text : tf.keras.layers.Layer] = {}
self._tf_layers: Dict[Text, tf.keras.layers.Layer] = {}
self._prepare_layers()

def _check_data(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion rasa/nlu/classifiers/diet_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ def __init__(
self._entity_tag_specs = self._ordered_tag_specs(entity_tag_specs)

# tf objects
self._tf_layers: Dict[Text : tf.keras.layers.Layer] = {}
self._tf_layers: Dict[Text, tf.keras.layers.Layer] = {}
self._prepare_layers()

# tf training
Expand Down