We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 54e3452 commit 6f8480cCopy full SHA for 6f8480c
docs/source/cheat_sheet_py3.rst
@@ -212,12 +212,13 @@ that are common in idiomatic Python are standardized.
212
# Mapping describes a dict-like object (with "__getitem__") that we won't
213
# mutate, and MutableMapping one (with "__setitem__") that we might
214
def f(my_dict: Mapping[int, str]) -> List[int]:
215
+ my_mapping[5] = 'maybe' # if we try this, mypy will throw an error...
216
return list(my_dict.keys())
217
218
f({3: 'yes', 4: 'no'})
219
220
def f(my_mapping: MutableMapping[int, str]) -> Set[str]:
- my_mapping[5] = 'maybe'
221
+ my_mapping[5] = 'maybe' # ...but mypy is OK with this.
222
return set(my_mapping.values())
223
224
0 commit comments