Skip to content

Commit 2ee6ac9

Browse files
committed
Turn on mypy type-checking in CI
1 parent b39639a commit 2ee6ac9

File tree

6 files changed

+20
-32
lines changed

6 files changed

+20
-32
lines changed

mypy.ini

+14-23
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,21 @@ exclude = (?x)(
1313
| ^setuptools/_distutils/ # Vendored
1414
| ^setuptools/config/_validate_pyproject/ # Auto-generated
1515
)
16-
disable_error_code =
17-
# TODO: Test environment is not yet properly configured to install all imported packages
18-
# import-not-found, # This can be left commented out for local runs until we enforce running mypy in the CI
19-
# TODO: Not all dependencies are typed. Namely: distutils._modified, wheel.wheelfile, and jaraco.*
20-
import-untyped,
21-
# Ignoring attr-defined because setuptools wraps a lot of distutils classes, adding new attributes,
22-
# w/o updating all the attributes and return types from the base classes for type-checkers to understand
23-
# Especially with setuptools.dist.command vs distutils.dist.command vs setuptools._distutils.dist.command
24-
# *.extern modules that actually live in *._vendor will also cause attr-defined issues on import
25-
attr-defined,
16+
# Ignoring attr-defined because setuptools wraps a lot of distutils classes, adding new attributes,
17+
# w/o updating all the attributes and return types from the base classes for type-checkers to understand
18+
# Especially with setuptools.dist.command vs distutils.dist.command vs setuptools._distutils.dist.command
19+
# *.extern modules that actually live in *._vendor will also cause attr-defined issues on import
20+
disable_error_code = attr-defined
2621

27-
# Avoid raising issues when importing from "extern" modules, as those are added to path dynamically.
28-
# https://github.com/pypa/setuptools/pull/3979#discussion_r1367968993
29-
[mypy-pkg_resources.extern.*,setuptools.extern.*]
22+
# - Avoid raising issues when importing from "extern" modules, as those are added to path dynamically.
23+
# https://github.com/pypa/setuptools/pull/3979#discussion_r1367968993
24+
# - distutils._modified has different errors on Python 3.8 [import-untyped], on Python 3.9+ [import-not-found]
25+
# - All jaraco modules are still untyped
26+
[mypy-pkg_resources.extern.*,setuptools.extern.*,distutils._modified,jaraco.*]
3027
ignore_missing_imports = True
3128

32-
[mypy-pkg_resources.tests.*,setuptools.tests.*]
33-
disable_error_code =
34-
# Tests include creating dynamic modules that won't exists statically before the test is run.
35-
# Let's ignore all "import-not-found", as if an import really wasn't found, then the test would fail.
36-
import-not-found,
37-
# mmany untyped "jaraco" modules
38-
import-untyped,
39-
40-
# Mypy issue, this vendored module is already excluded!
41-
[mypy-setuptools._vendor.packaging._manylinux]
29+
# - pkg_resources tests create modules that won't exists statically before the test is run.
30+
# Let's ignore all "import-not-found" since, if an import really wasn't found, then the test would fail.
31+
# - setuptools._vendor.packaging._manylinux: Mypy issue, this vendored module is already excluded!
32+
[mypy-pkg_resources.tests.*,setuptools._vendor.packaging._manylinux]
4233
disable_error_code = import-not-found

pyproject.toml

-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,3 @@ build-backend = "setuptools.build_meta"
44
backend-path = ["."]
55

66
[tool.setuptools_scm]
7-
8-
[tool.pytest-enabler.mypy]
9-
# disabled

setup.cfg

+4-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ testing =
4747
pytest-cov; \
4848
# coverage seems to make PyPy extremely slow
4949
python_implementation != "PyPy"
50-
pytest-mypy >= 0.9.1; \
51-
# workaround for jaraco/skeleton#22
52-
python_implementation != "PyPy"
50+
pytest-mypy
5351
pytest-enabler >= 2.2
5452
# workaround for pypa/setuptools#3921
5553
pytest-ruff >= 0.2.1; sys_platform != "cygwin"
@@ -66,13 +64,16 @@ testing =
6664
filelock>=3.4.0
6765
ini2toml[lite]>=0.9
6866
tomli-w>=1.0.0
67+
tomli
6968
pytest-timeout
7069
pytest-perf; \
7170
# workaround for jaraco/inflect#195, pydantic/pydantic-core#773 (see #3986)
7271
sys_platform != "cygwin"
7372
# for tools/finalize.py
7473
jaraco.develop >= 7.21; python_version >= "3.9" and sys_platform != "cygwin"
7574
pytest-home >= 0.5
75+
# No Python 3.12 dependencies require importlib_metadata, but needed for type-checking since we import it directly
76+
importlib_metadata; python_version >= "3.12"
7677

7778
testing-integration =
7879
pytest

setuptools/command/build_ext.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
try:
1818
# Attempt to use Cython for building extensions, if available
19-
from Cython.Distutils.build_ext import build_ext as _build_ext
19+
from Cython.Distutils.build_ext import build_ext as _build_ext # type: ignore[import-not-found] # Cython not installed on CI tests
2020

2121
# Additionally, assert that the compiler module will load
2222
# also. Ref #1229.

setuptools/command/editable_wheel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
from .install_scripts import install_scripts as install_scripts_cls
6060

6161
if TYPE_CHECKING:
62-
from wheel.wheelfile import WheelFile # noqa
62+
from wheel.wheelfile import WheelFile # type:ignore[import-untyped] # noqa
6363

6464
_P = TypeVar("_P", bound=StrPath)
6565
_logger = logging.getLogger(__name__)

setuptools/config/_validate_pyproject/fastjsonschema_validations.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# noqa
2-
# type: ignore
32
# flake8: noqa
43
# pylint: skip-file
54
# mypy: ignore-errors

0 commit comments

Comments
 (0)