Skip to content

mypy will never honor dependencies #733

Closed
@jaraco

Description

@jaraco

The current mypy config currently ignores dependencies by (a) not installing them and then (b) ignoring missing imports for those dependencies.

The non-installation of dependencies means that even for projects that have since added and declared typing support (both keyring and importlib_metadata fall into this boat), they're not tested.

I did find that if I repeated the dependencies in the type checks that the types appear to be checked, but that requires repeating the dependencies from setup.cfg (and thus keeping them in sync). e.g.:

twine feature/importlib-metadata-entry-points-select $ git diff
diff --git a/mypy.ini b/mypy.ini
index dc7d662..ddc192f 100644
--- a/mypy.ini
+++ b/mypy.ini
@@ -22,10 +22,6 @@ strict_equality = True
 ; https://github.com/tartley/colorama/issues/206
 ignore_missing_imports = True
 
-[mypy-importlib_metadata]
-; https://github.com/python/importlib_metadata/issues/10
-ignore_missing_imports = True
-
 [mypy-keyring]
 ; https://github.com/jaraco/keyring/issues/437
 ignore_missing_imports = True
diff --git a/tox.ini b/tox.ini
index ae3bc0e..bf5d3ce 100644
--- a/tox.ini
+++ b/tox.ini
@@ -73,6 +73,7 @@ skip_install = True
 deps =
     mypy
     lxml
+    importlib_metadata >= 3.6
 commands =
     mypy --html-report mypy --txt-report mypy {posargs:twine}
     python -c 'with open("mypy/index.txt") as f: print(f.read())'

Is that the intention, to keep a separate subset of dependencies in the 'types' check?

In my other projects, I enable ignore_missing_imports globally and let dependencies declare and implement typing support at their pace. Any reason not to do that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions