From f405c6f19e002ae13708cb33f6d48257cc1ea37a Mon Sep 17 00:00:00 2001 From: pgjones Date: Fri, 23 Apr 2021 09:44:15 +0100 Subject: [PATCH] Initial typing support This enables type checking in CI and marks the project as typed. --- .github/workflows/tests.yaml | 1 + MANIFEST.in | 1 + requirements/typing.in | 1 + requirements/typing.txt | 14 ++++++++++++++ setup.cfg | 27 +++++++++++++++++++++++++++ src/flask/py.typed | 0 tox.ini | 5 +++++ 7 files changed, 49 insertions(+) create mode 100644 requirements/typing.in create mode 100644 requirements/typing.txt create mode 100644 src/flask/py.typed diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 7d34bf78c2..e656dcf840 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -31,6 +31,7 @@ jobs: - {name: '3.7', python: '3.7', os: ubuntu-latest, tox: py37} - {name: '3.6', python: '3.6', os: ubuntu-latest, tox: py36} - {name: 'PyPy', python: pypy3, os: ubuntu-latest, tox: pypy3} + - {name: Typing, python: '3.9', os: ubuntu-latest, tox: typing} steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 diff --git a/MANIFEST.in b/MANIFEST.in index ddf882369f..65a9774968 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,4 +7,5 @@ graft docs prune docs/_build graft examples graft tests +include src/flask/py.typed global-exclude *.pyc diff --git a/requirements/typing.in b/requirements/typing.in new file mode 100644 index 0000000000..f0aa93ac8e --- /dev/null +++ b/requirements/typing.in @@ -0,0 +1 @@ +mypy diff --git a/requirements/typing.txt b/requirements/typing.txt new file mode 100644 index 0000000000..29e12e5e85 --- /dev/null +++ b/requirements/typing.txt @@ -0,0 +1,14 @@ +# +# This file is autogenerated by pip-compile +# To update, run: +# +# pip-compile requirements/typing.in +# +mypy-extensions==0.4.3 + # via mypy +mypy==0.812 + # via -r requirements/typing.in +typed-ast==1.4.3 + # via mypy +typing-extensions==3.7.4.3 + # via mypy diff --git a/setup.cfg b/setup.cfg index 9dee3575ca..7761686623 100644 --- a/setup.cfg +++ b/setup.cfg @@ -85,3 +85,30 @@ max-line-length = 80 per-file-ignores = # __init__ module exports names src/flask/__init__.py: F401 + +[mypy] +files = src/flask +python_version = 3.6 +allow_redefinition = True +disallow_subclassing_any = True +# disallow_untyped_calls = True +# disallow_untyped_defs = True +# disallow_incomplete_defs = True +no_implicit_optional = True +local_partial_types = True +# no_implicit_reexport = True +strict_equality = True +warn_redundant_casts = True +warn_unused_configs = True +warn_unused_ignores = True +# warn_return_any = True +# warn_unreachable = True + +[mypy-asgiref.*] +ignore_missing_imports = True + +[mypy-blinker.*] +ignore_missing_imports = True + +[mypy-dotenv.*] +ignore_missing_imports = True diff --git a/src/flask/py.typed b/src/flask/py.typed new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tox.ini b/tox.ini index cf12c0ebcc..d4558ad03d 100644 --- a/tox.ini +++ b/tox.ini @@ -2,6 +2,7 @@ envlist = py{39,38,37,36,py3} style + typing docs skip_missing_interpreters = true @@ -24,6 +25,10 @@ deps = pre-commit skip_install = true commands = pre-commit run --all-files --show-diff-on-failure +[testenv:typing] +deps = -r requirements/typing.txt +commands = mypy + [testenv:docs] deps = -r requirements/docs.txt