
Sept. 30, 2022
1:41 p.m.
As the problem of mutable data structures as function arguments is quite common (for example, List vs Sequence), maybe the problem should be solved at a more general level? Maybe there could be a way to indicate that a function argument should not be mutated. Something like ``` def f(x: Final[dict[str, int]]) -> None: x["foo"] = "bar" # type error! ``` Though really, function arguments should be non-mutable by default; mutating them is a somewhat weird thing to do. Maybe to mark it as mutable, you could do this? ``` def f(x: Mutable[dict[str, int]]) -> None: x["foo"] = "bar" # OK ```