Split import-untyped
into two different error codes depending on whether stubs are available to install
#18661
Labels
Feature
Implement separate error codes for (1) untyped imports without stubs available and (2) untyped imports with stubs available.
Pitch
As explained under Missing imports in the docs, there are two different categories of untyped imports. Currently, both of these categories are grouped under the
import-untyped
error code. For example:No stubs available (documented here):
Stubs available (documented here):
I propose that these categories should fall under different error codes, either by changing the error code for both of these categories (and removing the
import-untyped
error code) or by changing the error code for only one of the categories, and leaving the other asimport-untyped
. For example, the second category could fall under a newimport-untyped-stubs-available
code.This would allow configuring mypy to handle these two categories differently. For example, I would like to always ignore errors for untyped third-party libraries without stubs available, but always show errors for libraries with stubs available, so that I know which stub packages I should add to my project dependencies. The available solutions for achieving this all have drawbacks:
disable_error_code = import-untyped
ignores both of the above categories, so you won't be notified about libraries with available stubs.--install-types
option as part of CICD workflows is brittle and not recommended (see Option "install-types" breaks project version dependencies. #17852), so doesn't scale well when maintaining many different repositories where running--install-types
locally for every project on a regular basis is not feasible.import-untyped
error code for individual imports is again inconvenient when managing many different projects with many third-party dependencies. Also, if you ignore theimport-untyped
error code for a particular import and then the library later adds type stubs, mypy won't notify you that there is a stub package available to install.The text was updated successfully, but these errors were encountered: