Initial typing support

This enables type checking in CI and marks the project as typed.
This commit is contained in:
pgjones 2021-04-23 09:44:15 +01:00
parent c791f6312b
commit f405c6f19e
7 changed files with 49 additions and 0 deletions

View File

@ -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

View File

@ -7,4 +7,5 @@ graft docs
prune docs/_build
graft examples
graft tests
include src/flask/py.typed
global-exclude *.pyc

1
requirements/typing.in Normal file
View File

@ -0,0 +1 @@
mypy

14
requirements/typing.txt Normal file
View File

@ -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

View File

@ -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

0
src/flask/py.typed Normal file
View File

View File

@ -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