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

Dataclass deepcopy 1.10 #4963

Merged
merged 4 commits into from Feb 7, 2023
Merged

Dataclass deepcopy 1.10 #4963

merged 4 commits into from Feb 7, 2023

Conversation

mbillingr
Copy link

This PR adds a test and a fix for issue #4949.

resolves #4949

Copy link

@ezeparziale ezeparziale left a comment

Choose a reason for hiding this comment

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

👌

@kennethreitz
Copy link
Contributor

👍🏻

Copy link
Member

@PrettyWood PrettyWood 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 __copy__ and a test for that
I'd rather have only __copy__ and deepcopy fallbacking to it rather than only __deepcopy__.
Fine if you implement both methods though

@mbillingr
Copy link
Author

@PrettyWood Sure, I'll add __copy__.
While pondering how it should behave, I realized that Python does not copy types: copy(T) is T and deepcopy(T) is T.

Maybe DataclassProxy instances should behave like types and have __copy__/__deepcopy__ just return self?

@PrettyWood
Copy link
Member

@mbillingr Yes but here we speak about instances of DataclassProxy, not DataclassProxy itself.
So copy and deepcopy should return a new instance

@mbillingr
Copy link
Author

@PrettyWood you are right, of course. Although these instances are used like types they are not supposed to pretend to be types.

I have added a test and implementation for __copy__.
Also, I've made the assumption explicit in the tests that the copied thing is not the original .

Please review.

Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

LGTM, @PrettyWood please merge if you're happy.

Copy link

@ezeparziale ezeparziale left a comment

Choose a reason for hiding this comment

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

👌

@mbillingr
Copy link
Author

ping @PrettyWood
Just a small reminder that this PR is still around :)

@PrettyWood PrettyWood merged commit 0558af4 into pydantic:1.10.X-fixes Feb 7, 2023
@PrettyWood
Copy link
Member

Thank you so much

renovate bot added a commit to allenporter/flux-local that referenced this pull request Feb 18, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [pydantic](https://togithub.com/pydantic/pydantic) | `==1.10.4` ->
`==1.10.5` |
[![age](https://badges.renovateapi.com/packages/pypi/pydantic/1.10.5/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/pydantic/1.10.5/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/pydantic/1.10.5/compatibility-slim/1.10.4)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/pydantic/1.10.5/confidence-slim/1.10.4)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>pydantic/pydantic</summary>

###
[`v1.10.5`](https://togithub.com/pydantic/pydantic/releases/tag/v1.10.5):
(2023-02-15)

[Compare
Source](https://togithub.com/pydantic/pydantic/compare/v1.10.4...v1.10.5)

- Fix broken parametrized bases handling with `GenericModel`s with
complex sets of models,
[#&#8203;5052](https://togithub.com/pydantic/pydantic/issues/5052) by
[@&#8203;MarkusSintonen](https://togithub.com/MarkusSintonen)
- Invalidate mypy cache if plugin config changes,
[#&#8203;5007](https://togithub.com/pydantic/pydantic/issues/5007) by
[@&#8203;cdce8p](https://togithub.com/cdce8p)
- Fix `RecursionError` when deep-copying dataclass types wrapped by
pydantic,
[#&#8203;4949](https://togithub.com/pydantic/pydantic/issues/4949) by
[@&#8203;mbillingr](https://togithub.com/mbillingr)
- Fix `X | Y` union syntax breaking `GenericModel`,
[#&#8203;4146](https://togithub.com/pydantic/pydantic/issues/4146) by
[@&#8203;thenx](https://togithub.com/thenx)
- Switch coverage badge to show coverage for this branch/release,
[#&#8203;5060](https://togithub.com/pydantic/pydantic/issues/5060) by
[@&#8203;samuelcolvin](https://togithub.com/samuelcolvin)

#### New Contributors

- [@&#8203;thenx](https://togithub.com/thenx) made their first
contribution in
[pydantic/pydantic#4977
- [@&#8203;mbillingr](https://togithub.com/mbillingr) made their first
contribution in
[pydantic/pydantic#4963
- [@&#8203;MarkusSintonen](https://togithub.com/MarkusSintonen) made
their first contribution in
[pydantic/pydantic#5052

**Full Changelog**:
pydantic/pydantic@v1.10.4...v1.10.5

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/allenporter/flux-local).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xNDMuMSIsInVwZGF0ZWRJblZlciI6IjM0LjE0My4xIn0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
renovate bot added a commit to allenporter/pyrainbird that referenced this pull request Feb 18, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [pydantic](https://togithub.com/pydantic/pydantic) | `==1.10.4` ->
`==1.10.5` |
[![age](https://badges.renovateapi.com/packages/pypi/pydantic/1.10.5/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/pydantic/1.10.5/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/pydantic/1.10.5/compatibility-slim/1.10.4)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/pydantic/1.10.5/confidence-slim/1.10.4)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>pydantic/pydantic</summary>

###
[`v1.10.5`](https://togithub.com/pydantic/pydantic/releases/tag/v1.10.5):
(2023-02-15)

[Compare
Source](https://togithub.com/pydantic/pydantic/compare/v1.10.4...v1.10.5)

- Fix broken parametrized bases handling with `GenericModel`s with
complex sets of models,
[#&#8203;5052](https://togithub.com/pydantic/pydantic/issues/5052) by
[@&#8203;MarkusSintonen](https://togithub.com/MarkusSintonen)
- Invalidate mypy cache if plugin config changes,
[#&#8203;5007](https://togithub.com/pydantic/pydantic/issues/5007) by
[@&#8203;cdce8p](https://togithub.com/cdce8p)
- Fix `RecursionError` when deep-copying dataclass types wrapped by
pydantic,
[#&#8203;4949](https://togithub.com/pydantic/pydantic/issues/4949) by
[@&#8203;mbillingr](https://togithub.com/mbillingr)
- Fix `X | Y` union syntax breaking `GenericModel`,
[#&#8203;4146](https://togithub.com/pydantic/pydantic/issues/4146) by
[@&#8203;thenx](https://togithub.com/thenx)
- Switch coverage badge to show coverage for this branch/release,
[#&#8203;5060](https://togithub.com/pydantic/pydantic/issues/5060) by
[@&#8203;samuelcolvin](https://togithub.com/samuelcolvin)

#### New Contributors

- [@&#8203;thenx](https://togithub.com/thenx) made their first
contribution in
[pydantic/pydantic#4977
- [@&#8203;mbillingr](https://togithub.com/mbillingr) made their first
contribution in
[pydantic/pydantic#4963
- [@&#8203;MarkusSintonen](https://togithub.com/MarkusSintonen) made
their first contribution in
[pydantic/pydantic#5052

**Full Changelog**:
pydantic/pydantic@v1.10.4...v1.10.5

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/allenporter/pyrainbird).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xNDMuMSIsInVwZGF0ZWRJblZlciI6IjM0LjE0My4xIn0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants