python / python/mypy

Improve error message for type-abstract errors

Aperta
#18,711 0 commenti 1 reazione 1 assegnatario Vedi su GitHub

@sobolevn ci sta già lavorando.

Dal 22/2/2025.

feature topic-error-reporting
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Feature
Add more details to the [type-abstract] error message.

Pitch

If I have the following abstract base class

class BaseClass(abc.ABC):

    @abstractmethod
    def method1(self): ...

    @abstractmethod
    def method2(self): ...

    @abstractmethod
    def method3(self): ...

And later I make a subclass of that base class

class ExampleSubClass(BaseClass):

    def method1(self): ...

    def method2(self): ...

    #but I forgot to override method3

Then I will get the following error when I try to use ExampleSubClass in application code: Only concrete class can be given where "type[ExampleSubClass]" is expected [type-abstract]

It would be great if the error message specified why ExampleSubClass is not a concrete class. An ideal error message would look something like: "Only concrete class can be given where type[ExampleSubClass] is expected. ExampleSubClass has abstract methods [method3]"

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.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.