python-attrs / attrs

Python Classes Without Boilerplate

Home Page:https://www.attrs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Upgrade to 24.1.0 seems to break assignment to fields with chained converters

leroyvn opened this issue · comments

Upon upgrading to v24.1.0, I noticed that some of my code using fields with chained converters raises an AttributeError. Here is a MWE:

import attrs


def foo(x):
    return x


def bar(x):
    return x


@attrs.define
class MyClass:
    field = attrs.field(converter=[foo, bar])


x = MyClass(0)
x.field = 1
print(x)

That code runs successfully with v23.2.0, but it raises with the following stack trace with v24.1.0:

Traceback (most recent call last):
  File "/home/leroyv/Documents/src/rayference/rtm/eradiate/playgrounds/bug_attrs_241.py", line 18, in <module>
    x.field = 1
  File "/home/leroyv/miniforge3/envs/eradiate/lib/python3.9/site-packages/attr/_make.py", line 1057, in __setattr__
    nval = hook(self, a, val)
  File "/home/leroyv/miniforge3/envs/eradiate/lib/python3.9/site-packages/attr/setters.py", line 23, in wrapped_pipe
    rv = setter(instance, attrib, rv)
  File "/home/leroyv/miniforge3/envs/eradiate/lib/python3.9/site-packages/attr/setters.py", line 66, in convert
    return c(new_value)
AttributeError: __call__

yeah this is really bad, #1328 should fix it