python / python/mypy

Spurious errors on the builtin open when running mypy on mypy

Offen
#14,796 5 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduziere den Bericht mit Python 3.11, mypy 1.0.0 und dem dokumentierten Befehl unter Verwendung von --no-silence-site-packages und --disallow-any-unimported. Beginne mit der Untersuchung von typeshed/stdlib/builtins.pyi in der Nähe von Zeile 1327 und der Behandlung des eingebauten open; abgeschlossen ist die Aufgabe, wenn der Befehl die überflüssigen no-any-unimported-Fehler nicht mehr meldet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
devtools
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.