-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
base: master
Are you sure you want to change the base?
Fix/1920 #1921
Conversation
cc. @sobolevn |
There was a problem hiding this 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__): |
There was a problem hiding this comment.
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': |
There was a problem hiding this comment.
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.
I have made things!
Checklist
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.