From e57783863113d35e6398984e74de0060e4da9362 Mon Sep 17 00:00:00 2001 From: wisp3rwind <17089248+wisp3rwind@users.noreply.github.com> Date: Sat, 17 Dec 2022 22:20:33 +0100 Subject: [PATCH 1/3] add mypy tox environment and dependencies --- setup.py | 9 +++++++++ tox.ini | 10 +++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d49ed65b2..a6984ffd2 100755 --- a/setup.py +++ b/setup.py @@ -119,6 +119,15 @@ setup( 'flake8-docstrings', 'pep8-naming', ], + 'mypy': [ + 'mypy', + 'types-Pillow', + 'types-urllib3', + 'types-beautifulsoup4', + 'types-PyYAML', + 'types-requests', + 'types-Flask-Cors', + ], # Plugin (optional) dependencies: 'absubmit': ['requests'], diff --git a/tox.ini b/tox.ini index 1c0a984ed..861101e0f 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ # and then run "tox" from this directory. [tox] -envlist = py38-{cov,lint}, docs +envlist = py38-{cov,lint,mypy}, docs [_test] deps = .[test] @@ -13,15 +13,23 @@ deps = .[test] deps = .[lint] files = beets beetsplug beet test setup.py docs +[_mypy] +deps = + .[mypy] + .[test] + [testenv] deps = {test,cov}: {[_test]deps} lint: {[_lint]deps} + mypy: {[_mypy]deps} passenv = INTEGRATION_TEST commands = test: python -bb -m pytest -rs {posargs} cov: coverage run -m pytest -rs {posargs} lint: python -m flake8 {posargs} {[_lint]files} + mypy: mypy -p beets -p beetsplug + mypy: mypy test [testenv:docs] basepython = python3.10 From d604c7e175ed117162681d09770f81ae8677a9f4 Mon Sep 17 00:00:00 2001 From: wisp3rwind <17089248+wisp3rwind@users.noreply.github.com> Date: Sat, 17 Dec 2022 22:23:06 +0100 Subject: [PATCH 2/3] add mypy to actions, but allow failure --- .github/workflows/ci.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b3472e412..96b230c59 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -54,6 +54,15 @@ jobs: run: | tox -vv -e py-cov + - name: Test latest Python version with tox and mypy + if: matrix.python-version == '3.10' + # continue-on-error is not ideal since it doesn't give a visible + # warning, but there doesn't seem to be anything better: + # https://github.com/actions/toolkit/issues/399 + continue-on-error: true + run: | + tox -vv -e py-mypy + - name: Test nightly Python version with tox if: matrix.python-version == '3.11-dev' # continue-on-error is not ideal since it doesn't give a visible From d15c5c4ba246d5866c945342cc09b29d2e849c5c Mon Sep 17 00:00:00 2001 From: wisp3rwind <17089248+wisp3rwind@users.noreply.github.com> Date: Sat, 17 Dec 2022 22:32:30 +0100 Subject: [PATCH 3/3] mypy: ignore_missing_imports = True --- .mypy.ini | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .mypy.ini diff --git a/.mypy.ini b/.mypy.ini new file mode 100644 index 000000000..b47e5dff3 --- /dev/null +++ b/.mypy.ini @@ -0,0 +1,5 @@ +[mypy] +# FIXME: Would be better to actually type the libraries (if under our control), +# or write our own stubs. For now, silence errors +ignore_missing_imports = True +