False positive missing-super-call when parent method is abstract or protocol method without runtime implementation
@Aayushyaash ci sta già lavorando.
Dal 28/10/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Describe the Bug
Summary
When a subclass overrides a constructor-like method (__init__, __new__, or __init_subclass__) whose parent method has no runtime implementation (such as an @abstractmethod or a Protocol method with an empty/placeholder body like ..., pass, or raise NotImplementedError), Pyrefly reports a missing-super-call error.
However, accessing super().__init__ is rejected with missing-attribute by get_super_attribute (via super_method_needs_impl_reason / PR #5216, returning NoAccessReason::SuperMethodNeedsImplementation). As a result, the subclass cannot satisfy both checks simultaneously: omitting super() triggers missing-super-call, while adding super() triggers an error rejecting access to abstract parent methods without implementations.
Steps to Reproduce
Run pyrefly check on the following code with missing-super-call enabled (missing-super-call = "error" in config):
from abc import ABC, abstractmethod
class Base(ABC):
@abstractmethod
def __init__(self, x: int) -> None:
...
class Child(Base):
def __init__(self, x: int) -> None:
self.x = x
Observed Behavior
Pyrefly reports:
Method `Child.__init__` does not call the method of the same name in a parent class [missing-super-call]
If super().__init__(x) is added:
class Child(Base):
def __init__(self, x: int) -> None:
super().__init__(x)
self.x = x
Pyrefly reports:
Method `__init__` inherited from class `Base` has no implementation and cannot be accessed via `super()` [missing-attribute]
Expected Behavior
check_missing_super_call_for_field should not require calling super() on parent methods that have no runtime implementation. Specifically, in check_missing_super_call_for_field, candidate parent members where self.super_method_needs_impl_reason(&want_field).is_some() should be skipped, since accessing them via super() is disallowed.
Sandbox Link
(Only applicable for extension issues) IDE Information
No response
- Lingua principale
- Rust
- Stelle
- 7.2k
- Fork
- 578
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi 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.
Altre issue di facebook/pyrefly
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
-
Difficoltà 4/5 1-2 giorni Idoneità per principianti 54/100
-
dataframe
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
-
False positive missing-super-call on abstract or protocol method overrides with placeholder bodies in .py filesForse già presa @Aayushyaash l’ha presa oggi. Apertatypechecking
-
quansight
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
Tutte le issue di facebook/pyrefly
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
mozilla-services/syncstorage-rs#2715 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 70/100
-
documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
physicsdolphin/nv-uefi-unlocker#53 · 4 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
area/desktop-shell
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
yantrikos/yantrik-os#1012 ·
I maintainer di solito rispondono entro 1 giorno