Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created October 21, 2019 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NMZivkovic/e32c380740b48dfa196972545067eee6 to your computer and use it in GitHub Desktop.
Save NMZivkovic/e32c380740b48dfa196972545067eee6 to your computer and use it in GitHub Desktop.
from typing import TypedDict
class Song(TypedDict):
artist: str
title: str
album: str
year: int
song: Song = {'artist': 'Nikola Nezit', 'title': 'Three Suns Halo', 'album': 'Triad', 'year': 2013}
def getAlbum(song: Song):
return song['album']
# Wrong types
getAlbum({'artist': 11, 'title': 'Three Suns Halo', 'album': 'Triad', 'year': '2013'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment