You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/command_line.rst
+12-6Lines changed: 12 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -775,8 +775,8 @@ of the above sections.
775
775
.. option:: --extra-checks
776
776
777
777
This flag enables additional checks that are technically correct but may be
778
-
impractical. In particular, it prohibits partial overlap in ``TypedDict`` updates,
779
-
and makes arguments prepended via ``Concatenate`` positional-only. For example:
778
+
impractical. In particular, it prohibits partial overlap in ``TypedDict`` updates.
779
+
For example:
780
780
781
781
.. code-block:: python
782
782
@@ -790,14 +790,20 @@ of the above sections.
790
790
b: int
791
791
792
792
deftest(foo: Foo, bar: Bar) -> None:
793
-
# This is technically unsafe since foo can have a subtype of Foo at
794
-
# runtime, where type of key "b" is incompatible with int, see below
795
-
bar.update(foo)
793
+
# This is unsafe since foo can have a subtype of Foo at
794
+
# runtime, where type of key "b" is incompatible with int.
795
+
# See the usage below for an example of that unsafe situation.
796
+
bar.update(foo) # error: Argument 1 to "update" of "TypedDict" has incompatible type "Foo"; expected "TypedDict({'a': int, 'b'?: int})" [typeddict-item]
796
797
797
798
classBad(Foo):
798
799
b: str
799
800
bad: Bad = {"a": 0, "b": "no"}
800
-
test(bad, bar)
801
+
innocent_bar: Bar = Bar(a=1, b=1)
802
+
print(innocent_bar) # {'a': 1, 'b': 1}; types are correct, all is good.
803
+
test(bad, innocent_bar)
804
+
print(innocent_bar) # {'a': 0, 'b': 'no'}; types are now incorrect, uh oh.
805
+
806
+
It also makes arguments prepended via ``Concatenate`` positional-only.
801
807
802
808
In future more checks may be added to this flag if:
0 commit comments