Repository: samuelcolvin/pydantic
Pull request #4037 (2022-05-01 21:00:45)

build(deps): bump pytest from 7.1.1 to 7.1.2
Bumps [pytest](https://github.com/pytest-dev/pytest) from 7.1.1 to 7.1.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/pytest-dev/pytest/releases">pytest's releases</a>.</em></p>
<blockquote>
<h2>7.1.2</h2>
<h1>pytest 7.1.2 (2022-04-23)</h1>
<h2>Bug Fixes</h2>
<ul>
<li><a href="https://github-redirect.dependabot.com/pytest-dev/pytest/issues/9726">#9726</a>: An unnecessary <code>numpy</code> import inside <code>pytest.approx</code>{.interpreted-text role=&quot;func&quot;} was removed.</li>
<li><a href="https://github-redirect.dependabot.com/pytest-dev/pytest/issues/9820">#9820</a>: Fix comparison of <code>dataclasses</code> with <code>InitVar</code>.</li>
<li><a href="https://github-redirect.dependabot.com/pytest-dev/pytest/issues/9869">#9869</a>: Increase <code>stacklevel</code> for the <code>NODE_CTOR_FSPATH_ARG</code> deprecation to point to the
user's code, not pytest.</li>
<li><a href="https://github-redirect.dependabot.com/pytest-dev/pytest/issues/9871">#9871</a>: Fix a bizarre (and fortunately rare) bug where the [temp_path]{.title-ref} fixture could raise
an internal error while attempting to get the current user's username.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/pytest-dev/pytest/commit/2f2f1a601e33aa1a77de42f164ba4b642252f1c0"><code>2f2f1a6</code></a> Prepare release version 7.1.2</li>
<li><a href="https://github.com/pytest-dev/pytest/commit/5c04f3a1a2151a6d72203ed058ff4f8a50e97691"><code>5c04f3a</code></a> [7.1.x] Fix wrong <code>log_file</code> docs (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest/issues/9879">#9879</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest/commit/078733c00511a0af711abc5bc56af4bfbcab7baf"><code>078733c</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/pytest-dev/pytest/issues/9872">#9872</a> from pytest-dev/backport-9871-to-7.1.x</li>
<li><a href="https://github.com/pytest-dev/pytest/commit/3a7ead6bcf2facd28819fed69abe79cdf90f5e10"><code>3a7ead6</code></a> [7.1.x] fix: move 'import getpass' statement to try-clause</li>
<li><a href="https://github.com/pytest-dev/pytest/commit/6d753337806e708ab00987e7ed3edd913b586f5c"><code>6d75333</code></a> [7.1.x] Increase stacklevel to point at user's code (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest/issues/9870">#9870</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest/commit/ddbb998aed82c599886d31b3a48930042b623463"><code>ddbb998</code></a> [7.1.x] Increase stacklevel to point at user's code</li>
<li><a href="https://github.com/pytest-dev/pytest/commit/0ec5886ad5aa3c872d7645db494f9ab0aebe0230"><code>0ec5886</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/pytest-dev/pytest/issues/9855">#9855</a> from pytest-dev/backport-9854-to-7.1.x</li>
<li><a href="https://github.com/pytest-dev/pytest/commit/f2469fca374efe9b0e93e1749ec6afe785016ca2"><code>f2469fc</code></a> [7.1.x] Docs: link to easy issues in contributing guide</li>
<li><a href="https://github.com/pytest-dev/pytest/commit/94ec0f8ad86fe3ba58c9a4114028afcc50e3c292"><code>94ec0f8</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/pytest-dev/pytest/issues/9846">#9846</a> from pytest-dev/backport-9842-to-7.1.x</li>
<li><a href="https://github.com/pytest-dev/pytest/commit/5ef96fdb5390b1c232b42559f3460947739282d3"><code>5ef96fd</code></a> [7.1.x] fix comparison of dataclasses with <code>InitVar</code></li>
<li>Additional commits viewable in <a href="https://github.com/pytest-dev/pytest/compare/7.1.1...7.1.2">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pytest&package-manager=pip&previous-version=7.1.1&new-version=7.1.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 08b22ce39..607016890 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -246,9 +246,6 @@ jobs:
       with:
         python-version: '3.10'
 
-    - name: upgrade pip
-      run: pip install -U pip setuptools wheel
-
     - name: install
       run: make install-testing
 
diff --git a/changes/3641-PrettyWood.md b/changes/3641-PrettyWood.md
new file mode 100644
index 000000000..d0338c663
--- /dev/null
+++ b/changes/3641-PrettyWood.md
@@ -0,0 +1,1 @@
+`Config.copy_on_model_validation` does a deep copy and not a shallow one
\ No newline at end of file
diff --git a/docs/requirements.txt b/docs/requirements.txt
index 8c28433d5..da19a20fc 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -6,7 +6,7 @@ markdown-include==0.6.0
 mdx-truly-sane-lists==1.2
 mkdocs==1.3.0
 mkdocs-exclude==1.0.2
-mkdocs-material==8.2.8
+mkdocs-material==8.2.12
 sqlalchemy
 orjson
 ujson
diff --git a/pydantic/main.py b/pydantic/main.py
index eea8abcbb..1dcda9efd 100644
--- a/pydantic/main.py
+++ b/pydantic/main.py
@@ -666,7 +666,7 @@ class BaseModel(Representation, metaclass=ModelMetaclass):
     def validate(cls: Type['Model'], value: Any) -> 'Model':
         if isinstance(value, cls):
             if cls.__config__.copy_on_model_validation:
-                return value._copy_and_set_values(value.__dict__, value.__fields_set__, deep=False)
+                return value._copy_and_set_values(value.__dict__, value.__fields_set__, deep=True)
             else:
                 return value
 
diff --git a/requirements.txt b/requirements.txt
index 3beeb0fdb..71a0fbf00 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,5 +4,5 @@ Cython==0.29.28;sys_platform!='win32'
 devtools==0.8.0
 email-validator==1.1.3
 dataclasses==0.6; python_version < '3.7'
-typing-extensions==4.1.1
+typing-extensions==4.2.0
 python-dotenv==0.20.0


Test patch:
diff --git a/tests/requirements-testing.txt b/tests/requirements-testing.txt
index f29e6454b..5721960d3 100644
--- a/tests/requirements-testing.txt
+++ b/tests/requirements-testing.txt
@@ -3,7 +3,7 @@ hypothesis==6.41.0
 # pin importlib-metadata as upper versions need typing-extensions to work if on python < 3.8
 importlib-metadata==3.1.0;python_version<"3.8"
 mypy==0.942
-pytest==7.1.1
+pytest==7.1.2
 pytest-cov==3.0.0
 pytest-mock==3.7.0
 pytest-sugar==0.9.4
diff --git a/tests/test_main.py b/tests/test_main.py
index c00d70688..f4d3844c4 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -1561,12 +1561,28 @@ def test_model_exclude_copy_on_model_validation():
 
     assert t.user is not my_user
     assert t.user.hobbies == ['scuba diving']
-    assert t.user.hobbies is my_user.hobbies  # `Config.copy_on_model_validation` only does a shallow copy
+    assert t.user.hobbies is not my_user.hobbies  # `Config.copy_on_model_validation` does a deep copy
     assert t.user._priv == 13
     assert t.user.password.get_secret_value() == 'hashedpassword'
     assert t.dict() == {'id': '1234567890', 'user': {'id': 42, 'hobbies': ['scuba diving']}}
 
 
+def test_validation_deep_copy():
+    """By default, Config.copy_on_model_validation should do a deep copy"""
+
+    class A(BaseModel):
+        name: str
+
+    class B(BaseModel):
+        list_a: List[A]
+
+    a = A(name='a')
+    b = B(list_a=[a])
+    assert b.list_a == [A(name='a')]
+    a.name = 'b'
+    assert b.list_a == [A(name='a')]
+
+
 @pytest.mark.parametrize(
     'kinds',
     [