From d8fd5b740b3e7b6f4f77ba5d3ca66ebec4e42bc4 Mon Sep 17 00:00:00 2001 From: Kanishk Pachauri Date: Fri, 30 Aug 2024 01:41:01 +0530 Subject: [PATCH 1/2] Add 3.13 to CI --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 57103fab1..6e319564c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.9', '3.10', '3.11', '3.12'] + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] steps: - uses: actions/checkout@v4 From 3723f675b0f304008fbbaff77dee20a7bd0ec0df Mon Sep 17 00:00:00 2001 From: Kanishk Pachauri Date: Fri, 30 Aug 2024 01:47:28 +0530 Subject: [PATCH 2/2] Add __replace__ magic method to Container base class --- returns/primitives/container.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/returns/primitives/container.py b/returns/primitives/container.py index b4ac79367..078b9195b 100644 --- a/returns/primitives/container.py +++ b/returns/primitives/container.py @@ -66,6 +66,12 @@ def __setstate__(self, state: Union[_PickleState, Any]) -> None: # backward compatibility with 0.19.0 and earlier object.__setattr__(self, '_inner_value', state) # noqa: WPS609 + def __replace__(self, **changes: Any) -> 'BaseContainer': + """Create a new instance with specified changes.""" + if set(changes.keys()) - set(self.__slots__): + raise ValueError("Invalid attribute(s) specified") + new_inner_value = changes.get('_inner_value', self._inner_value) + return type(self)(new_inner_value) def container_equality( self: Kind1[_EqualType, Any],