1. Declare a class based on TypedDict and add it as a type annotation to the field that holds your dictionary.
2. Run your type checker and fix all type validation issues, if it reports any.
3. For every call site that uses any dict facility other than get/set (if there are any), define methods in your class and change the call site to use those. Note that this step is the same thing as the whole technique that the article is about, just with the twist that you only have to do this for operations that are not get nor set, which are likely to be few and far between.
4. Remove the `TypedDict` mixin from your class. At the same time, replace all the dict get/set invocations with plain property interactions. (You can do this safely in one fell swoop, because the type checker has your back.) If everything passes the type check, you're done.
Yes! TypedDict is fantastic for migrating dicts that have outgrown, into more appropriate containers, such as dataclasses. So good in fact that you can often skip step 3 and 4. Assuming the rest of your code has the type annotations wherever such objects are passed through, otherwise the runtime check from the article still has some merit.
1. Declare a class based on TypedDict and add it as a type annotation to the field that holds your dictionary.
2. Run your type checker and fix all type validation issues, if it reports any.
3. For every call site that uses any dict facility other than get/set (if there are any), define methods in your class and change the call site to use those. Note that this step is the same thing as the whole technique that the article is about, just with the twist that you only have to do this for operations that are not get nor set, which are likely to be few and far between.
4. Remove the `TypedDict` mixin from your class. At the same time, replace all the dict get/set invocations with plain property interactions. (You can do this safely in one fell swoop, because the type checker has your back.) If everything passes the type check, you're done.