Skip to content

Commit

Permalink
Update dictionary.md
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelCurrin authored Dec 15, 2023
1 parent b03c7d0 commit f68cf7f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cheatsheets/python/type-checks/data-structures/dictionary.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f68cf7f

Please sign in to comment.