Skip to content

Commit 9265aac

Browse files
committed
mypy check for untyped imports
1 parent e329c0a commit 9265aac

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

mypy.ini

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,20 @@ exclude = (?x)(
1313
| ^setuptools/_distutils/ # Vendored
1414
| ^setuptools/config/_validate_pyproject/ # Auto-generated
1515
)
16-
disable_error_code =
17-
# TODO: Not all dependencies are typed. Namely: distutils._modified, wheel.wheelfile, and jaraco.*
18-
; import-untyped,
19-
# Ignoring attr-defined because setuptools wraps a lot of distutils classes, adding new attributes,
20-
# w/o updating all the attributes and return types from the base classes for type-checkers to understand
21-
# Especially with setuptools.dist.command vs distutils.dist.command vs setuptools._distutils.dist.command
22-
# *.extern modules that actually live in *._vendor will also cause attr-defined issues on import
23-
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
2421

2522
# Avoid raising issues when importing from "extern" modules, as those are added to path dynamically.
2623
# https://github.com/pypa/setuptools/pull/3979#discussion_r1367968993
27-
[mypy-pkg_resources.extern.*,setuptools.extern.*]
24+
# All jaraco modules are still untyped
25+
[mypy-pkg_resources.extern.*,setuptools.extern.*,jaraco.*]
2826
ignore_missing_imports = True
2927

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

setuptools/command/build_clib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from distutils import log
44

55
try:
6-
from distutils._modified import newer_pairwise_group # type: ignore[import-not-found]
6+
from distutils._modified import newer_pairwise_group # type: ignore[import-untyped]
77
except ImportError:
88
# fallback for SETUPTOOLS_USE_DISTUTILS=stdlib
99
from .._distutils._modified import newer_pairwise_group

setuptools/command/editable_wheel.py

Lines changed: 1 addition & 1 deletion
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
_Path = Union[str, Path]
6565
_P = TypeVar("_P", bound=_Path)

0 commit comments

Comments
 (0)