Skip to content

Commit

Permalink
Merge #157
Browse files Browse the repository at this point in the history
157: Vector.__reduce__: Do not invoke __new__ directly r=astronouth7303 a=nbraud

This fixes a violation of the [protocol] for object construction:

> If `__new__` returns an instance of `cls`, then the new instance’s `__init__()` method will be invoked like `__init__(self[, ...])`, where `self` is the new instance and the remaining arguments are the same as were passed to `__new__`.

[protocol]: https://docs.python.org/3/reference/datamodel.html#object.__new__

@astronouth7303 seems [in agreement](#146 (comment))

Co-authored-by: Nicolas Braud-Santoni <nicolas@braud-santoni.eu>
  • Loading branch information
bors[bot] and nbraud committed May 24, 2019
2 parents 5d4f447 + 34b087c commit 51b681f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ppb_vector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def __new__(cls, *args, **kwargs):
return self

def __reduce__(self):
return Vector.__new__, (Vector, self.x, self.y)
return Vector, (self.x, self.y)

#: Return a new :py:class:`Vector` replacing specified fields with new values.
update = dataclasses.replace
Expand Down

0 comments on commit 51b681f

Please sign in to comment.