Skip to content

Commit

Permalink
Enable stricter type checks that require little to no code change
Browse files Browse the repository at this point in the history
Contributes to #425
  • Loading branch information
AWhetter committed Aug 29, 2024
1 parent 00ee104 commit ce69512
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion autoapi/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"method",
"attribute",
]
_VIEWCODE_CACHE: Dict[str, Tuple[str, Dict]] = {}
_VIEWCODE_CACHE: Dict[str, tuple[str, dict[str, tuple[str, int, int]]]] = {}
"""Caches a module's parse results for use in viewcode."""


Expand Down
1 change: 1 addition & 0 deletions docs/changes/425.misc.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enable stricter type checks that require little to no code changes
35 changes: 18 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@
requires = ["setuptools>=46.4.0"]
build-backend = "setuptools.build_meta"

[tool.mypy]
# Start off with these
warn_unused_configs = true
warn_redundant_casts = true
warn_unused_ignores = true

# Getting these passing should be easy
strict_equality = true

# These shouldn't be too much additional work, but may be tricky to
# get passing if you use a lot of untyped libraries
disallow_subclassing_any = true
disallow_untyped_decorators = true
disallow_any_generics = true

# This one isn't too hard to get passing, but return on investment is lower
no_implicit_reexport = true

[[tool.mypy.overrides]]
module = "astroid.*"
ignore_missing_imports = true
Expand All @@ -12,32 +30,15 @@ ignore_errors = true

[[tool.mypy.overrides]]
module = "autoapi._astroid_utils"
# Start off with these
# warn_unused_configs = true <-- can only be set globally
# warn_redundant_casts = true <-- can only be set globally
warn_unused_ignores = true

# Getting these passing should be easy
strict_equality = true
strict_concatenate = true

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

# These shouldn't be too much additional work, but may be tricky to
# get passing if you use a lot of untyped libraries
disallow_subclassing_any = true
disallow_untyped_decorators = true
disallow_any_generics = true

# These next few are various gradations of forcing use of type annotations
disallow_untyped_calls = true
disallow_incomplete_defs = true
disallow_untyped_defs = true

# This one isn't too hard to get passing, but return on investment is lower
no_implicit_reexport = true

# This one can be tricky to get passing if you use a lot of untyped libraries
# Ignore until astroid is typed (https://github.com/pylint-dev/astroid/issues/2060)
warn_return_any = false
Expand Down

0 comments on commit ce69512

Please sign in to comment.