stubgen infers function returns None if it passes or raise NotImplementedError
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
-
Are you reporting a bug, or opening a feature request?
Reporting a bug, although I'm not sure what the intended behavior is. -
Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
class A:
def f(self):
raise NotImplementedError
def g(self):
"""A is not an abstract base class"""
return "Hello World"
class B(A):
def f(self):
return 5
class C:
def f(self):
pass
- What is the actual behavior/output?
stubgen output:
class A:
def f(self) -> None: ...
def g(self): ...
class B(A):
def f(self): ...
class C:
def f(self) -> None: ...
- What is the behavior/output you expect?
class A:
def f(self): ...
def g(self): ...
class B(A):
def f(self): ...
class C:
def f(self): ...
This is because I would like to write code like
def h(a: A):
return a.f()
h(B())
without typing errors. In realistic use cases, A has multiple subclasses.
- What are the versions of mypy and Python you are using?
Python 3.7.7
mypy 0.782
Do you see the same issue after installing mypy from Git master?
Yes
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
Partite dal comportamento di stubgen mostrato nell’issue e riproducetelo usando l’esempio A, B e C. Tracciate il modo in cui stubgen inferisce le annotazioni del valore restituito per i metodi che propagano o sollevano NotImplementedError, quindi verificate che gli stub generati non aggiungano più None in questi casi, preservando al contempo i metodi delle sottoclassi mostrati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 48/100