Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/1920 #1921

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions returns/primitives/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I was wrong about adding this method to BaseContainer base class. I think that we need to add this to Unwrappable (?) instead. Basically, right now - this is not type-safe at all.

And add a proper type annotations. And add type tests for it.

"""Create a new instance with specified changes."""
if set(changes.keys()) - set(self.__slots__):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we can simplify this to only allow _inner_value change. Nothing else.

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],
Expand Down
Loading