Split `import-untyped` into two different error codes depending on whether stubs are available to install
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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):
error: Skipping analyzing "boto3": module is installed, but missing library stubs or py.typed marker [import-untyped] -
Stubs available (documented here):
error: Library stubs not installed for "requests" [import-untyped] note: Hint: "python3 -m pip install types-requests"
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 as import-untyped. For example, the second category could fall under a new import-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:
- Using
disable_error_code = import-untypedignores both of the above categories, so you won't be notified about libraries with available stubs. - Using the
--install-typesoption as part of CICD workflows is brittle and not recommended (see https://github.com/python/mypy/issues/17852), so doesn't scale well when maintaining many different repositories where running--install-typeslocally for every project on a regular basis is not feasible. - Ignoring the
import-untypederror code for individual imports is again inconvenient when managing many different projects with many third-party dependencies. Also, if you ignore theimport-untypederror 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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dalla documentazione collegata “Missing imports” e traccia il punto in cui vengono prodotti i due diagnostici import-untyped mostrati e i relativi codici di errore. Esamina la configurazione esistente dei codici di errore e i test correlati, quindi definisci codici separati il cui comportamento distingua gli stub non disponibili da quelli installabili.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100