Skip to content

We should make JsonDict default to stricter type checking, now that it's possible #20103

Description

@reivilibre

In 0a2456f I introduced StrictJsonDict (and a family of related 'strict' JSON types), after discovering that this has become possible. (In the past we had trouble getting Mypy to accept a recursive type definition.)

Our current codebase norm is to use JsonDict which is defined as dict[str, Any].
I suspect there are more instances of under-validated JSON being propagated that are concealed by the Any in JsonDict.

I intend to repoint JsonDict to be strict, which will involve adding appropriate validation in some places.
I will introduce a LaxJsonDict type with the old definition, with the intention of using this in test code where we currently need it (as otherwise we will probably have to insert more verbose checks into our test code).

I will then attempt to fix up code that relies on JsonDict = LaxJsonDict and drive down the number of errors that occur from a changeover. I would like to avoid polluting git blame everywhere by doing a tree-wide rename, so I'll rely on doing the work upfront before a single changeover.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions