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

Fix/1920 #1921

wants to merge 2 commits into from

Conversation

Mr-Sunglasses
Copy link

@Mr-Sunglasses Mr-Sunglasses commented Aug 29, 2024

I have made things!

Checklist

  • I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)
  • I have created at least one test case for the changes I have made
  • I have updated the documentation for the changes I have made
  • I have added my changes to the CHANGELOG.md

Related issues

fix: #1920

🙏 Please, if you or your company finds dry-python valuable, help us sustain the project by sponsoring it transparently on https://github.com/sponsors/dry-python. As a thank you, your profile/company logo will be added to our main README which receives hundreds of unique visitors per day.

@Mr-Sunglasses
Copy link
Author

I have made things!

Checklist

* [x]  I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)

* [ ]  I have created at least one test case for the changes I have made

* [ ]  I have updated the documentation for the changes I have made

* [ ]  I have added my changes to the `CHANGELOG.md`

Related issues

fix: #1920

🙏 Please, if you or your company finds dry-python valuable, help us sustain the project by sponsoring it transparently on https://github.com/sponsors/dry-python. As a thank you, your profile/company logo will be added to our main README which receives hundreds of unique visitors per day.

cc. @sobolevn

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Please, add tests cases for:

  • Empty replace
  • Replace with correct value
  • Replace with incorrect values

@@ -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__):
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.

@@ -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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Support copy.replace from 3.13
2 participants