Skip to content

Commit a33c387

Browse files
committed
Enable mypy on CI
1 parent 0435c72 commit a33c387

File tree

6 files changed

+20
-29
lines changed

6 files changed

+20
-29
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
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ testing =
7373
# for tools/finalize.py
7474
jaraco.develop >= 7.21; python_version >= "3.9" and sys_platform != "cygwin"
7575
pytest-home >= 0.5
76+
# No Python 3.11 dependencies require tomli, but needed for type-checking since we import it directly
77+
tomli
78+
# No Python 3.12 dependencies require importlib_metadata, but needed for type-checking since we import it directly
79+
importlib_metadata
7680

7781
testing-integration =
7882
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)