Type annotations for Enum value

前端 未结 3 1168
甜味超标
甜味超标 2020-12-03 06:40

I have this piece of code:

import enum


class Color(enum.Enum):
    RED = \'1\'
    BLUE = \'2\'
    GREEN = \'3\'


def get_color_return_something(some_col         


        
3条回答
  •  我在风中等你
    2020-12-03 07:17

    Type hinting the Color class should work:

    def get_color_return_something(some_color: Color):
        print(some_color.value)
    

提交回复
热议问题