Skip to content

Commit b89a581

Browse files
committed
Type checking improvements
- Add a PEP 561 marker file (py.typed). - Run mypy during CI. - Update black to avoid pallets/click#2225
1 parent 54b2b2b commit b89a581

File tree

5 files changed

+85
-2
lines changed

5 files changed

+85
-2
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DEFAULT_GOAL := all
22
isort = isort devtools tests
33
black = black -S -l 120 --target-version py37 devtools
4+
mypy = mypy devtools
45

56
.PHONY: install
67
install:
@@ -18,6 +19,7 @@ lint:
1819
flake8 devtools/ tests/
1920
$(isort) --check-only --df
2021
$(black) --check --diff
22+
$(mypy)
2123

2224
.PHONY: test
2325
test:

devtools/py.typed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# PEP-561 marker. https://mypy.readthedocs.io/en/latest/installed_packages.html

mypy.ini

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
[mypy]
2+
3+
# Import discovery
4+
mypy_path = devtools
5+
namespace_packages = true
6+
7+
# Disallow dynamic typing
8+
disallow_any_unimported = true
9+
disallow_any_expr = false
10+
disallow_any_decorated = false
11+
disallow_any_explicit = false
12+
disallow_any_generics = false
13+
disallow_subclassing_any = true
14+
15+
# Untyped definitions and calls
16+
disallow_untyped_calls = false
17+
disallow_untyped_defs = false
18+
disallow_incomplete_defs = true
19+
check_untyped_defs = true
20+
disallow_untyped_decorators = true
21+
22+
# None and Optional handling
23+
no_implicit_optional = true
24+
strict_optional = true
25+
26+
# Configuring warning
27+
warn_redundant_casts = true
28+
warn_unused_ignores = true
29+
warn_no_return = true
30+
warn_return_any = false
31+
warn_unreachable = true
32+
33+
# Suppressing errors
34+
show_none_errors = true
35+
ignore_errors = false
36+
37+
# Miscellaneous strictness flags
38+
allow_untyped_globals = false
39+
allow_redefinition = false
40+
implicit_reexport = false
41+
strict_equality = true
42+
43+
# Configuring error messages
44+
show_error_context = true
45+
show_column_numbers = true
46+
show_error_codes = true
47+
pretty = true
48+
color_output = true
49+
error_summary = true
50+
show_absolute_path = true
51+
52+
# Advanced options
53+
show_traceback = true
54+
raise_exceptions = true
55+
56+
# Miscellaneous
57+
warn_unused_configs = true
58+
verbosity = 0
59+
60+
#
61+
# Please do not add any additional mypy ignores in this section!
62+
#
63+
64+
[mypy-devtools.utils]
65+
# FIXME: Remove this ignore after fixing type errors.
66+
ignore_errors = true
67+
68+
[mypy-devtools.prettier]
69+
# FIXME: Remove this ignore after fixing type errors.
70+
ignore_errors = true
71+
72+
[mypy-devtools.ansi]
73+
# FIXME: Remove this ignore after fixing type errors.
74+
ignore_errors = true
75+
76+
[mypy-devtools.debug]
77+
# FIXME: Remove this ignore after fixing type errors.
78+
ignore_errors = true

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
url='https://github.com/samuelcolvin/python-devtools',
5050
license='MIT',
5151
packages=['devtools'],
52+
package_data={"devtools": ["py.typed"]},
5253
python_requires='>=3.6',
5354
install_requires=[
5455
'executing>=0.8.0,<1.0.0',

tests/requirements-linting.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
black==20.8b1
1+
black==22.3.0
22
flake8==3.9.2
33
isort==5.9.3
4-
mypy==0.910
4+
mypy==0.950
55
pycodestyle==2.7.0
66
pyflakes==2.3.1
7+
types-Pygments==2.9.19

0 commit comments

Comments
 (0)