Skip to content

Commit e680011

Browse files
committed
add docs
1 parent 778f8b7 commit e680011

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/source/error_code_list.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,25 @@ Warn about cases where a bytes object may be converted to a string in an unexpec
11511151
print(f"The alphabet starts with {b!r}") # The alphabet starts with b'abc'
11521152
print(f"The alphabet starts with {b.decode('utf-8')}") # The alphabet starts with abc
11531153
1154+
.. _code-str-unpack:
1155+
1156+
Check that ``str`` is not unpacked [str-unpack]
1157+
---------------------------------------------------------
1158+
1159+
It can sometimes be surprising that ``str`` is iterable, especially when unpacking
1160+
in an assignment.
1161+
1162+
Example:
1163+
1164+
.. code-block:: python
1165+
1166+
def print_dict(d: dict[str, str]) -> int:
1167+
# We meant to do d.items(), but instead we're unpacking the str keys of d
1168+
1169+
# Error: Unpacking a string is disallowed
1170+
for k, v in d:
1171+
print(k, v)
1172+
11541173
.. _code-overload-overlap:
11551174

11561175
Check that overloaded functions don't overlap [overload-overlap]

0 commit comments

Comments
 (0)