python / python/mypy

__i<magic>__ method incompatible with __<magic>__ of superclass

Offen
#6,225 7 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@Michael0x2a arbeitet bereits daran.

Seit 19.1.2019.

bug documentation needs discussion priority-1-normal
Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

I'm recieving an a error within folowing code:

class A:
    def __add__(self, other) -> int:
        ...
    def __iadd__(self, other) -> 'A':
        ...

class C(A):
    #  error: Return type of "__iadd__" incompatible with "__add__" of supertype "A"
    def __iadd__(self, other) -> 'C':
        ...

I'm not sure that __add__ and __iadd__ methods have to be compatible.
And, if belief to the MyPy in the signature of class A, that not produce the error, MyPy also doesn't think they have to be compatible...

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.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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