Can a Python function be annotated with a list of potential return values?
RAINY = 'rainy'
SUNNY = 'sunny'
CLOUDY = 'cloudy'
SNOWY = 'snowy'
TYPES_OF_WEATHER = [RAINY, SUNNY, CLOUDY, SNOWY]
def today_is_probably(season) -> OneOf[TYPES_OF_WEATHER]:
if season is 'spring':
return RAINY
if season is 'summer':
return SUNNY
if season is 'autumn':
return CLOUDY
if season is 'winter':
return SNOWY