Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Support evolving to a subclass (possibly any class)

Open
#1,088 8 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
python

Research direction

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.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Python
Stars
5.9k
Forks
499
Avg merge
3d 12h
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python-attrs/attrs

All issues in python-attrs/attrs

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.