How to annotate an IntEnum value

Eko palypse ekopalypse at gmail.com
Tue Sep 3 08:57:20 EDT 2019


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:
    pass


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:
    pass

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.



More information about the Python-list mailing list