python / python/mypy

Spurious errors on the builtin open when running mypy on mypy

Aperta
#14,796 5 commenti 2 reazioni 0 assegnatari Vedi su GitHub

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

When running mypy following the procedure below, I encounter several errors for the overloaded open builtin of the form:

../python3.11/site-packages/mypy/typeshed/stdlib/builtins.pyi:1327: error: Argument 8 to "open" becomes "Optional[Any]" due to an unfollowed import  [no-any-unimported]

To reproduce:

  1. Set up a virtualenv with Python 3.11 and activate it.
  2. pip install mypy
  3. python-m mypy --strict --no-silence-site-packages --disallow-any-unimported -m mypy

Both --no-silence-site-packages and --disallow-any-unimported need to be present.

Version 1.0.0 of mypy is required. Older versions don't exhibit this error.

This is the simplest way we have found to reproduce this problem, but we first encountered it in one of our own projects.

The issue is being filed here because the mypy docs for reporting bugs says that problems with a specific library function should be reported here. We're not seeing this error with any other functions.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riproduci il report con Python 3.11, mypy 1.0.0 e il comando documentato usando --no-silence-site-packages e --disallow-any-unimported. Inizia esaminando typeshed/stdlib/builtins.pyi intorno alla riga 1327 e la gestione dell'open incorporato; il lavoro è completato quando il comando non segnala più gli errori no-any-unimported spuri.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
devtools
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.