vega / altair

Declarative statistical visualization library for Python
https://altair-viz.github.io/
BSD 3-Clause "New" or "Revised" License
9.4k stars 795 forks source link

fix: Resolve `Then` copy `TypeError` #3553

Closed dangotbanned closed 3 months ago

dangotbanned commented 3 months ago

Fixes


I originally thought https://github.com/vega/altair/pull/3543 introduced this regression.

Haven't tested on earlier branches, but @mattijn can you check if you can repro on v5.4.0? I think it would be present on there as well

dangotbanned commented 3 months ago

Thanks for fixing this @dangotbanned. I tried it out and as you mentioned, the error is raised on 5.4.0 as well. In fact, it is present all the way back to the commit that merged #3427, so it seems to have been there since the new alt.when functionality was added.

The fix here looks good to me 👍

Thanks for the review @joelostblom

For anyone searching in the future, what I added is a very basic implementation of copy.deepcopy. Which has a memo parameter, and that is why Then.__deepcopy__ does as well.

https://github.com/python/cpython/blob/74ff496dce9f7db1dd1e2184d4316cc21d78ee52/Lib/copy.py#L119-L179