1 SUSPECT #1
from typing import overload
@overload
def proc(x: int) -> int: ...
@overload
def proc(x: str) -> str: ...
def proc(x):
return x * 2
print(proc([1, 2])) # (no error β typing.overload is decorator-only documentation,
# no runtime dispatch β list * 2 doubles the list)
[1, 2, 1, 2] 2 SUSPECT #2
import contextlib
@contextlib.contextmanager
def tag(name):
print(f"<{name}>")
yield
print(f"</{name}>")
with tag("b"):
print("hello") # (no error)
<b>
hello
</b> 3 SUSPECT #3
name = "ada"
prefix = b"user:"
print(prefix + name) Traceback (most recent call last):
File "lineup.py", line 3, in <module>
print(prefix + name)
~~~~~~~^~~~~~~
TypeError: unsupported operand type(s) for +: 'bytes' and 'str' 4 SUSPECT #4
from dataclasses import dataclass, replace
@dataclass(frozen=True)
class Point:
x: int
y: int
p = Point(1, 2)
p2 = replace(p, x=10)
print(p2) # (no error β replace() is the canonical way to evolve frozen dataclasses)
Point(x=10, y=2) 5 SUSPECT #5
from enum import Enum
class Color(Enum):
RED = 1
BLUE = 1 # duplicate value
print(Color.RED is Color.BLUE) # (no error β Enum aliases duplicates by default)
True