From f68cf7f36c9c306df29550ddfc4492d84b63da1a Mon Sep 17 00:00:00 2001 From: Michael Currin <18750745+MichaelCurrin@users.noreply.github.com> Date: Fri, 15 Dec 2023 16:33:52 +0100 Subject: [PATCH] Update dictionary.md --- .../type-checks/data-structures/dictionary.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cheatsheets/python/type-checks/data-structures/dictionary.md b/cheatsheets/python/type-checks/data-structures/dictionary.md index f9c925b15..9971d14f9 100644 --- a/cheatsheets/python/type-checks/data-structures/dictionary.md +++ b/cheatsheets/python/type-checks/data-structures/dictionary.md @@ -17,7 +17,7 @@ So you can validate that a dictionary passed around meets the following: - Fields are only null when allowed to be. -## Using plain Dict +## Use a plain dict Here we create a type using a dictionary. @@ -99,6 +99,18 @@ Here are using a `Movie` type, defined as follows: Movie = TypedDict('Movie', {'name': str, 'year': int}) ``` +A nested example: + +```python +FooBar = TypedDict( + "FooBar", + { + "Id": str, + "Status": TypedDict("Status", {"Id": int, "Name": str}), + }, +) +``` + The 4 approaches are: #### Annotation