Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Include default
data
value in function signature
Include default `data` value (an empty dict) in function signature. We cannot use a normal empty dict because using a mutable data type as a default argument value in a function is almost always a bad idea. Indeed, doing this is perhaps the canonical gotcha in Python programming. See <https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments> for a full description of the problem. With the arrival of type annotations, however, we really do want to indicate that the default value is an empty dict. We indicate default values everywhere else, so not doing it in this case is confusing. The solution here is to create a superficial implementation of `frozendict` (which really should be part of the standard library, alongside `frozenset`). See the rejected PEP416 for why it is not in the standard library. Thanks to @smoh for identifying the flaw in the documentation.
- Loading branch information