Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

False positive missing-super-call when parent method is abstract or protocol method without runtime implementation

Aperta
#5,430 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@Aayushyaash ci sta già lavorando.

Dal 28/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

typechecking
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

https://pyrefly.org/sandbox/?project=v2.pZRBDoIwEEWv0oQFsKCNLlkpXMADsEFosIkCoWDq7f1tUSBgo5GEzXT6J-m8_52ROUuOY5IC5jMQgZQlPNMbx29dleSSB-gCQaMDD-v2D4ZTMVY5d9rYqj9K6XJQisWWu0DPm2b9KGoMrPCgakN7_6f20PIuCOn7igq3R68B8sjJFsi4C0QnyKsGBDSIolntIZs5ufR9K2PGXtebrmK8ZmVTSLa4wYj2Sn7PhYn9pRxpDPASsg5yv2DXt-j6LnJ9DS46IHAVheijvH7ostFGnavt-k1I5FQVmVeNCnhwOnWC_QQ

(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

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.

Altre issue di facebook/pyrefly

Tutte le issue di facebook/pyrefly

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.