python / mypy

Optional static typing for Python
https://www.mypy-lang.org/
Other
18.53k stars 2.83k forks source link

Allow TypedDict assignment of Required item to NotRequired ReadOnly item #18164

Closed brianschubert closed 3 days ago

brianschubert commented 3 days ago

Fixes #18162

brianschubert commented 3 days ago

With this, mypy passes the typeddicts_readonly_consistency conformance tests :tada:

diff --git a/conformance/results/mypy/typeddicts_readonly_consistency.toml b/conformance/results/mypy/typeddicts_readonly_consistency.toml
index ea01b2d..cff41c9 100644
--- a/conformance/results/mypy/typeddicts_readonly_consistency.toml
+++ b/conformance/results/mypy/typeddicts_readonly_consistency.toml
@@ -6,13 +6,11 @@ output = """
 typeddicts_readonly_consistency.py:37: error: Incompatible types in assignment (expression has type "A1", variable has type "B1")  [assignment]
 typeddicts_readonly_consistency.py:38: error: Incompatible types in assignment (expression has type "C1", variable has type "B1")  [assignment]
 typeddicts_readonly_consistency.py:40: error: Incompatible types in assignment (expression has type "A1", variable has type "C1")  [assignment]
-typeddicts_readonly_consistency.py:79: error: Incompatible types in assignment (expression has type "C2", variable has type "A2")  [assignment]
 typeddicts_readonly_consistency.py:81: error: Incompatible types in assignment (expression has type "A2", variable has type "B2")  [assignment]
 typeddicts_readonly_consistency.py:82: error: Incompatible types in assignment (expression has type "C2", variable has type "B2")  [assignment]
 typeddicts_readonly_consistency.py:84: error: Incompatible types in assignment (expression has type "A2", variable has type "C2")  [assignment]
 typeddicts_readonly_consistency.py:85: error: Incompatible types in assignment (expression has type "B2", variable has type "C2")  [assignment]
 """
-conformance_automated = "Fail"
+conformance_automated = "Pass"
 errors_diff = """
-Line 79: Unexpected errors ['typeddicts_readonly_consistency.py:79: error: Incompatible types in assignment (expression has type "C2", variable has type "A2")  [assignment]']
 """
diff --git a/conformance/results/mypy/version.toml b/conformance/results/mypy/version.toml
index bdefc8c..7aa48eb 100644
--- a/conformance/results/mypy/version.toml
+++ b/conformance/results/mypy/version.toml
@@ -1,2 +1,2 @@
-version = "mypy 1.13.0"
-test_duration = 2.7
+version = "mypy 1.14.0+dev.4e88ddb672cd5eef3be48cf8bbfe641969b860ac"
+test_duration = 4.7
github-actions[bot] commented 3 days ago

Diff from mypy_primer, showing the effect of this PR on open source code:

discord.py (https://github.com/Rapptz/discord.py): 1.40x slower (299.8s -> 419.7s in a single noisy sample)