python / python/mypy

`--disallow-untyped-calls` reports errors in untyped functions

Aperta
#12,912 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Bug Report

Using --disallow-untyped-calls and --check-untyped-defs results in errors about calling untyped functions in a typed context, even when calling from an untyped function.

To Reproduce

Test case:

[case testDisallowUntypedCallsFromUntypedFunction]
# flags: --disallow-untyped-calls --check-untyped-defs

def f(x):
    pass

def g(y):
    f(y)

Expected Behavior

Either:

  • the documentation and the error message should be updated to specify that --disallow-untyped-calls disallows all calls to untyped functions, regardless of whether the current function has type annotations, or
  • the above code shouldn't produce any errors

Actual Behavior

The call to f in the above example produces the error "Call to untyped function "f" in typed context".

Your Environment

See https://mypy-play.net/?mypy=latest&python=3.10&flags=check-untyped-defs%2Cdisallow-untyped-calls&gist=3350fe27968b29dabc5ef1e207d008ce to reproduce.

This came up in #12901 (specifically the mypy_primer diff had an error here)

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

Inizia con il test case chiamato testDisallowUntypedCallsFromUntypedFunction e riproducilo con --disallow-untyped-calls e --check-untyped-defs. Traccia come viene classificata la chiamata a f all’interno di g, quindi stabilisci se la correzione prevista consiste nell’aggiornare la documentazione e la formulazione oppure nel modificare il comportamento in modo che il test non generi più errori.

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
38/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.