Skip to content

Commit

Permalink
Add "make typecheck" target and run it during gitlab CI
Browse files Browse the repository at this point in the history
- Add mypy to requirements.txt
- Add mypy.ini
- Add testenv:mypy to tox.ini
- Add a make typecheck target
- Add a typecheck section to .gitlab-ci.yml

Closes #1006
  • Loading branch information
appleby committed Nov 7, 2019
1 parent cadae56 commit c0c9d00
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ style:
- make requirements
- make style

typecheck:
image: python:3.6
tags:
- github
script:
- make install
- make requirements
- make typecheck

docs:
image: python:3.6
tags:
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ style:
test:
pytest -v --runslow --cov=pyquil

# The dream is to one day run mypy on the whole tree. For now, limit
# checks to known-good files.
.PHONY: typecheck
typecheck:
mypy pyquil/quilatom.py pyquil/quilbase.py pyquil/gates.py

.PHONY: upload
upload:
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
Expand Down
24 changes: 24 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[mypy]
# We'd like to leave follow_imports and ignore_missing_imports at
# their default values, but there are too many errors to fix for now.
follow_imports = silent
ignore_missing_imports = True

# Enable options equivalent to the --strict command line arg
warn_unused_configs = True
disallow_subclassing_any = True
disallow_any_generics = True
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
check_untyped_defs = True
disallow_untyped_decorators = True
no_implicit_optional = True
warn_redundant_casts = True
warn_unused_ignores = True
warn_return_any = True
no_implicit_reexport = True

# Ignore errors in generated parser files
[mypy-pyquil._parser.gen3.*]
ignore_errors = True
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pytest-timeout
pytest-rerunfailures
requests-mock
flake8
mypy
tox

# docs
Expand Down
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py36, py37, docs, flake8
envlist = py36, py37, docs, flake8, mypy

[testenv]
recreate=
Expand All @@ -20,3 +20,7 @@ commands = flake8 pyquil
[flake8]
ignore = E501,E999,E741,E126,E127,F401,F403,F405,F811,F841,E743,W503
exclude = gen3,external

[testenv:mypy]
# The dream is to one day run mypy on the whole tree. For now, limit checks to known-good files.
commands = mypy pyquil/quilatom.py pyquil/quilbase.py pyquil/gates.py

0 comments on commit c0c9d00

Please sign in to comment.