From 7a06ccfa06b51e6f30b12cab32cfb2fd9162acc8 Mon Sep 17 00:00:00 2001 From: pvragov Date: Wed, 1 Dec 2021 13:36:45 +0700 Subject: [PATCH] fix document_enum typing --- enum_tools/documentation.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/enum_tools/documentation.py b/enum_tools/documentation.py index 7a283a3..db73747 100644 --- a/enum_tools/documentation.py +++ b/enum_tools/documentation.py @@ -29,7 +29,7 @@ import sys from enum import Enum, EnumMeta from textwrap import dedent -from typing import Iterable, List, Optional, Tuple +from typing import Iterable, List, Optional, Tuple, TypeVar # 3rd party import pygments.token # type: ignore @@ -49,6 +49,8 @@ INTERACTIVE = bool(getattr(sys, "ps1", sys.flags.interactive)) +EnumType = TypeVar("EnumType", bound=EnumMeta) + def get_tokens(line: str) -> List[Tuple]: """ @@ -60,7 +62,7 @@ def get_tokens(line: str) -> List[Tuple]: return list(lexer.get_tokens(line)) -def document_enum(an_enum: EnumMeta) -> EnumMeta: +def document_enum(an_enum: EnumType) -> EnumType: """ Document all members of an enum by adding a comment to the end of each line that starts with ``doc:``.