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

`__getattr__` in child class gets called when mixed with `cached_property`

Aperta
#1,288 10 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
tooling

Direzione di ricerca

Start by running the Python reproduction from the issue with attrs and functools.cached_property. Trace how the inherited cached_property is resolved when Sup defines getattr, then add a regression test for b.howdy. Done means the existing cached property is returned without calling Sup.getattr.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

from functools import cached_property
from attrs import define

@define
class Bob:
    @cached_property
    def howdy(self):
        return 3

class Sup(Bob):
    def __getattr__(self, name):
        raise AttributeError(name)

b = Sup()

# reaches __getattr__ where I raise AttributeError
b.howdy

This previously did not error. I would expect __getattr__ to not be called since the attribute exists.

Lingua principale
Python
Stelle
5.8k
Fork
480
Merge medio
2h 15m
PR unite (30g)
2

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.

Altre issue di python-attrs/attrs

Tutte le issue di python-attrs/attrs

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.