Skip to content

Commit 13f0b07

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 - Update mkdocs to avoid mkdocs/mkdocs#2799 - Disable mkdocs strict mode to avoid mkdocs/mkdocs#2252
1 parent 54b2b2b commit 13f0b07

File tree

7 files changed

+99
-4
lines changed

7 files changed

+99
-4
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

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ansi2html==1.5.2
2-
mkdocs==1.1.2
2+
mkdocs==1.2.4
33
markdown==3.2.2
44
mkdocs-exclude==1.0.2
55
mkdocs-material==5.5.0

mkdocs.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
site_name: python-devtools
22
site_description: Python's missing debug print command and other development tools.
3-
strict: true
3+
strict: false
44
site_url: https://python-devtools.helpmanual.io/
55

66
theme:
@@ -12,6 +12,18 @@ theme:
1212

1313
repo_name: samuelcolvin/python-devtools
1414
repo_url: https://github.com/samuelcolvin/python-devtools
15+
16+
#
17+
# FIXME: google_analytics is deprecated. This section must be replaced with
18+
# something like this instead:
19+
#
20+
# analytics:
21+
# gtag: G-123456
22+
#
23+
# Once this is replaced, re-enable strict mode at the top of this file.
24+
#
25+
# See https://github.com/mkdocs/mkdocs/issues/2252 for details.
26+
#
1527
google_analytics:
1628
- 'UA-62733018-4'
1729
- 'auto'

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)