| ▲ | arthur-st 43 minutes ago | |
Typing spec has some detailed info if you'd like https://typing.python.org/en/latest/spec/typeddict.html Summarizing, for something that is an argument with specific fields you'd use a Mapping or a MutableMapping as the annotation, and if that's a return value, then it should be a TypedDict. Sometimes TypedDict also makes sense as an argument annotation, e.g., if it has to be a dict strictly. For a generic dictionary, like you know that you're drawing from a set of possible kwargs that are all string values, you can also just annotate them with an "anonymous" dict like what Ty is inferring on your codebase. | ||