[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to annotate an IntEnum value

Suppose the following

from enum import IntEnum

class ENDOFLINE(IntEnum):
    CRLF = 0
    CR = 1
    LF = 2

def get_eol() -> ??:
    return ENDOFLINE.CRLF 

def set_eol(eol_value) -> None:

How should the return value from get_eol be annotated? As ENDOFLINE?
The same question for set_eol function, is it assumed to see the following declaration?

def set_eol(value: ENDOFLINE) -> None:

I've tried to see what pep484 suggests but either I haven't understood it
or it doesn't go into detail in such a case.