File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff 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
11561175Check that overloaded functions don't overlap [overload-overlap]
You can’t perform that action at this time.
0 commit comments