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

Support evolving to a subclass (possibly any class)

Aperta
#1,088 8 commenti 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
35/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
python

Direzione di ricerca

Start by reading the existing attrs.evolve implementation and its surrounding public API behavior. Clarify whether evolving to unrelated classes is supported or only subclass targets, then define the expected result and compatibility behavior before identifying the tests needed to confirm the chosen design.

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

Descrizione

Feature

Recently I wrote a modification to the attrs.evolve function that works like this:

@attrs.define
class Foo:
  a: int

@attrs.define
class Bar(Foo):
  b: str

foo = Foo(1)
bar = evolve_as(foo, Bar, b="2")
print(bar)
# Bar(a=1, b='2')

This was very useful for my particular use-case, which involved enriching a data object in a pipeline, so I thought that this might be a good fit for attrs.

My implementation did not require Bar to be a subclass of Foo, but I'm not sure about the design implications of that. Might be better to limit this to subclasses only.

Lingua principale
Python
Stelle
5.9k
Fork
499
Merge medio
3g 12h
PR unite (30g)
3

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 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.