Skip to content

Commit ce69512

Browse files
committed
Enable stricter type checks that require little to no code change
Contributes to #425
1 parent 00ee104 commit ce69512

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

autoapi/extension.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"method",
4141
"attribute",
4242
]
43-
_VIEWCODE_CACHE: Dict[str, Tuple[str, Dict]] = {}
43+
_VIEWCODE_CACHE: Dict[str, tuple[str, dict[str, tuple[str, int, int]]]] = {}
4444
"""Caches a module's parse results for use in viewcode."""
4545

4646

docs/changes/425.misc.1

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Enable stricter type checks that require little to no code changes

pyproject.toml

+18-17
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22
requires = ["setuptools>=46.4.0"]
33
build-backend = "setuptools.build_meta"
44

5+
[tool.mypy]
6+
# Start off with these
7+
warn_unused_configs = true
8+
warn_redundant_casts = true
9+
warn_unused_ignores = true
10+
11+
# Getting these passing should be easy
12+
strict_equality = true
13+
14+
# These shouldn't be too much additional work, but may be tricky to
15+
# get passing if you use a lot of untyped libraries
16+
disallow_subclassing_any = true
17+
disallow_untyped_decorators = true
18+
disallow_any_generics = true
19+
20+
# This one isn't too hard to get passing, but return on investment is lower
21+
no_implicit_reexport = true
22+
523
[[tool.mypy.overrides]]
624
module = "astroid.*"
725
ignore_missing_imports = true
@@ -12,32 +30,15 @@ ignore_errors = true
1230

1331
[[tool.mypy.overrides]]
1432
module = "autoapi._astroid_utils"
15-
# Start off with these
16-
# warn_unused_configs = true <-- can only be set globally
17-
# warn_redundant_casts = true <-- can only be set globally
18-
warn_unused_ignores = true
19-
20-
# Getting these passing should be easy
21-
strict_equality = true
22-
strict_concatenate = true
2333

2434
# Strongly recommend enabling this one as soon as you can
2535
check_untyped_defs = true
2636

27-
# These shouldn't be too much additional work, but may be tricky to
28-
# get passing if you use a lot of untyped libraries
29-
disallow_subclassing_any = true
30-
disallow_untyped_decorators = true
31-
disallow_any_generics = true
32-
3337
# These next few are various gradations of forcing use of type annotations
3438
disallow_untyped_calls = true
3539
disallow_incomplete_defs = true
3640
disallow_untyped_defs = true
3741

38-
# This one isn't too hard to get passing, but return on investment is lower
39-
no_implicit_reexport = true
40-
4142
# This one can be tricky to get passing if you use a lot of untyped libraries
4243
# Ignore until astroid is typed (https://github.com/pylint-dev/astroid/issues/2060)
4344
warn_return_any = false

0 commit comments

Comments
 (0)