Skip to content

Commit

Permalink
Tox.ini: Run mypy in ignore_outcome mode (spec-first#1405)
Browse files Browse the repository at this point in the history
* Tox.ini: Run mypy in allow errors mode

* py39: mypy

* touch .mypy_cache

* Make sure .mypy_cache exists

* Update tox.ini

* mkdir .mypy_cache

* mkdir .mypy_cache

* mkdir .mypy_cache

* mypy --install-types --non-interactive . || true

* mypy --exclude=/examples/ --install-types --non-interactive . || true

* mypy --exclude /examples/ --install-types --non-interactive .

* mypy --exclude /examples/* --install-types --non-interactive .

* mypy --exclude '/app\.py$' --install-types --non-interactive .

* mypy --exclude '/(app|hello)\.py$' --install-types --non-interactive .

* mypy --exclude '/(api|app|hello)\.py$' --install-types --non-interactive .

* mypy --exclude '/(__init__|api|app|hello)\.py$' --install-types --non-interactive .

* mypy --exclude '/(__init__|api|api.pets|app|hello)\.py$' --install-types --non-interactive .

* mypy --exclude '/(__init__|api|api.pets|app|hello|resty)\.py$' --install-types --non-interactive .

* mypy --exclude '/(__init__|api|api.pets|app|hello|orm|resty)\.py$' --install-types --non-interactive .

* Update pipeline.yml

* Update tox.ini

* Update pipeline.yml

* Update tox.ini

* Update mypy invocation and fix typing errors

Make it such that mypy will not return an exit code 2, which
indicates a failure in running mypy itself.

Co-authored-by: Ruwan <ruwanlambrichts@gmail.com>
  • Loading branch information
cclauss and Ruwann committed Aug 23, 2021
1 parent 65c1fab commit 8c49a61
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
25 changes: 13 additions & 12 deletions tests/api/test_parameters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
from io import BytesIO
from typing import List

import pytest

Expand Down Expand Up @@ -43,31 +44,31 @@ def test_array_query_param(simple_app):
headers = {'Content-type': 'application/json'}
url = '/v1.0/test_array_csv_query_param'
response = app_client.get(url, headers=headers)
array_response = json.loads(response.data.decode('utf-8', 'replace')) # type: [str]
array_response: List[str] = json.loads(response.data.decode('utf-8', 'replace'))
assert array_response == ['squash', 'banana']
url = '/v1.0/test_array_csv_query_param?items=one,two,three'
response = app_client.get(url, headers=headers)
array_response = json.loads(response.data.decode('utf-8', 'replace')) # type: [str]
array_response: List[str] = json.loads(response.data.decode('utf-8', 'replace'))
assert array_response == ['one', 'two', 'three']
url = '/v1.0/test_array_pipes_query_param?items=1|2|3'
response = app_client.get(url, headers=headers)
array_response = json.loads(response.data.decode('utf-8', 'replace')) # type: [int]
array_response: List[int] = json.loads(response.data.decode('utf-8', 'replace'))
assert array_response == [1, 2, 3]
url = '/v1.0/test_array_unsupported_query_param?items=1;2;3'
response = app_client.get(url, headers=headers)
array_response = json.loads(response.data.decode('utf-8', 'replace')) # [str] unsupported collectionFormat
array_response: List[str] = json.loads(response.data.decode('utf-8', 'replace')) # unsupported collectionFormat
assert array_response == ["1;2;3"]
url = '/v1.0/test_array_csv_query_param?items=A&items=B&items=C&items=D,E,F'
response = app_client.get(url, headers=headers)
array_response = json.loads(response.data.decode('utf-8', 'replace')) # type: [str] multi array with csv format
array_response: List[str] = json.loads(response.data.decode('utf-8', 'replace')) # multi array with csv format
assert array_response == ['D', 'E', 'F']
url = '/v1.0/test_array_multi_query_param?items=A&items=B&items=C&items=D,E,F'
response = app_client.get(url, headers=headers)
array_response = json.loads(response.data.decode('utf-8', 'replace')) # type: [str] multi array with csv format
array_response: List[str] = json.loads(response.data.decode('utf-8', 'replace')) # multi array with csv format
assert array_response == ['A', 'B', 'C', 'D', 'E', 'F']
url = '/v1.0/test_array_pipes_query_param?items=4&items=5&items=6&items=7|8|9'
response = app_client.get(url, headers=headers)
array_response = json.loads(response.data.decode('utf-8', 'replace')) # type: [int] multi array with pipes format
array_response: List[int] = json.loads(response.data.decode('utf-8', 'replace')) # multi array with pipes format
assert array_response == [7, 8, 9]


Expand All @@ -76,25 +77,25 @@ def test_array_form_param(simple_app):
headers = {'Content-type': 'application/x-www-form-urlencoded'}
url = '/v1.0/test_array_csv_form_param'
response = app_client.post(url, headers=headers)
array_response = json.loads(response.data.decode('utf-8', 'replace')) # type: [str]
array_response: List[str] = json.loads(response.data.decode('utf-8', 'replace'))
assert array_response == ['squash', 'banana']
url = '/v1.0/test_array_csv_form_param'
response = app_client.post(url, headers=headers, data={"items": "one,two,three"})
array_response = json.loads(response.data.decode('utf-8', 'replace')) # type: [str]
array_response: List[str] = json.loads(response.data.decode('utf-8', 'replace'))
assert array_response == ['one', 'two', 'three']
url = '/v1.0/test_array_pipes_form_param'
response = app_client.post(url, headers=headers, data={"items": "1|2|3"})
array_response = json.loads(response.data.decode('utf-8', 'replace')) # type: [int]
array_response: List[int] = json.loads(response.data.decode('utf-8', 'replace'))
assert array_response == [1, 2, 3]
url = '/v1.0/test_array_csv_form_param'
data = 'items=A&items=B&items=C&items=D,E,F'
response = app_client.post(url, headers=headers, data=data)
array_response = json.loads(response.data.decode('utf-8', 'replace')) # type: [str] multi array with csv format
array_response: List[str] = json.loads(response.data.decode('utf-8', 'replace')) # multi array with csv format
assert array_response == ['D', 'E', 'F']
url = '/v1.0/test_array_pipes_form_param'
data = 'items=4&items=5&items=6&items=7|8|9'
response = app_client.post(url, headers=headers, data=data)
array_response = json.loads(response.data.decode('utf-8', 'replace')) # type: [int] multi array with pipes format
array_response: List[int] = json.loads(response.data.decode('utf-8', 'replace')) # multi array with pipes format
assert array_response == [7, 8, 9]


Expand Down
13 changes: 12 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ envlist =
isort-check-examples
isort-check-tests
flake8
mypy

[gh-actions]
python =
3.6: py36-min,py36-pypi
3.7: py37-min,py37-pypi
3.8: py38-min,py38-pypi
3.9: py39-min,py39-pypi,flake8,isort-check,isort-check-examples,isort-check-tests
3.9: py39-min,py39-pypi,flake8,isort-check,isort-check-examples,isort-check-tests,mypy

[testenv]
setenv=PYTHONPATH = {toxinidir}:{toxinidir}
Expand Down Expand Up @@ -57,3 +58,13 @@ basepython=python3
deps=isort==5.9.1
changedir={toxinidir}/tests
commands=isort --thirdparty aiohttp,connexion --check-only --diff .

[testenv:mypy]
deps=
mypy==0.910
types-PyYAML
types-requests
types-setuptools
types-ujson
ignore_outcome=true
commands=mypy --exclude='examples/' connexion tests

0 comments on commit 8c49a61

Please sign in to comment.