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

Issue with `__init_subclass__` when not decorated as classmethod

Aperta
#366 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
python
Ambito
testing

Direzione di ricerca

Il report riguarda la gestione delle mutazioni per i metodi Python init_subclass che si basano sulla conversione implicita in classmethod. Inizia esaminando il file del mutante generato e il percorso di mutazione per init_subclass, quindi confronta il comportamento con e senza @classmethod; il lavoro è completato quando l’AttributeError segnalato è compreso e il caso interessato dispone di un test di regressione chiaro o di una limitazione documentata.

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

Descrizione

Hi, thanks for a great project!

I was stuck for a while on an issue where some attributes were not found properly from a mutated method (somehow object.__get_attribute__ was failing where getattr was succeeding, the context was on an ABCMeta object but I could not find anything related):

AttributeError: 'ABCMeta' object has no attribute 'xǁAntaTestǁ__init_subclass____mutmut_orig'. Did you mean: 'xǁAntaTestǁ__init_subclass____mutmut_1'?

It turns out, the issue was around the __init_subclass__ method that we have defined without a classmethod decorator. As per documentation: https://docs.python.org/3/reference/datamodel.html#customizing-class-creation the method is implicitly converted to classmethod if not declared as such.

As soon as I added the @classmethod decorator, I could move forward (to the next error but that's on me to solve).

From what I can see in the mutant file, __init_subclass__ is not mutated anymore so maybe not ideal.

Anyways, thought I would put this out there if it can help others ending up in the same situation. Feel free to close the issue.

Lingua principale
Python
Stelle
1.5k
Fork
179
Merge medio
11m
PR unite (30g)
2

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 boxed/mutmut

Tutte le issue di boxed/mutmut

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.