python / python/mypy

(🎁) Option to not report errors from stub bodies

Offen
#12,196 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

feature priority-2-low
Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

test.py:

import foo
foo.foo("")

stubs/foo/init.pyi:

def foo(i: int) -> None:
    1 + ""

mypy test.py

stubs/foo/__init__.pyi:2: error: Unsupported operand types for + ("int" and "str")
test.py:2: error: Argument 1 to "foo" has incompatible type "str"; expected "int"
Found 2 errors in 2 files (checked 1 source file)

In when I'm working with mypy I basically copy-paste the src of libraries into a stubs folder and gradually type them as needed, but it's a pain when I get errors on the bodies of functions like

stubs/x/y/z.pyi error: Call to untyped function "amongus" in typed context  [no-untyped-call]

The bodies of stub functions shouldn't need to be typechecked imo and there should be an option to disable this.

I don't delete the bodies of the functions because that would be a lot of work, and it is kinda convinient that the impl and types are in the same place.

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

Use the test.py and stubs/foo/init.pyi reproducer and run mypy test.py. Trace how diagnostics from stub function bodies are produced, then verify an option suppresses those diagnostics while retaining the call-site argument error.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
compilers, tooling
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

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