From ceaa7d92e900bdf2382fba94fa455d2683a13ee0 Mon Sep 17 00:00:00 2001 From: John Turner Date: Wed, 6 Mar 2024 14:43:03 -0500 Subject: [PATCH] dependencies.py: use Enum rather than StrEnum for DependencyKind StrEnum is only supported in Python versions 3.11 and newer. Gentoolkit should not require >=3.11, so DependencyKind will use the regular Enum feature instead. The difference between StrEnum and Enum is that StrEnum members are strings and can generally be used in place of strings in APIs expecting string input. Non-StrEnum members are not strings, but you can get members values by accessing their value field (DependencyKind.DEPEND.value). --- pym/gentoolkit/dependencies.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pym/gentoolkit/dependencies.py b/pym/gentoolkit/dependencies.py index f296e27c..c6abff0b 100644 --- a/pym/gentoolkit/dependencies.py +++ b/pym/gentoolkit/dependencies.py @@ -13,7 +13,7 @@ import itertools from functools import cache -from enum import StrEnum +from enum import Enum from typing import List, Dict import portage @@ -28,7 +28,7 @@ # ======= -class DependencyKind(StrEnum): +class DependencyKind(Enum): DEPEND = "DEPEND" RDEPEND = "RDEPEND" BDEPEND = "BDEPEND" @@ -104,13 +104,13 @@ def _get_depend(self, env_vars, raw=False): @cache def get_raw_depends(self) -> str: - return self._get_depend([depkind for depkind in DependencyKind], raw=True) + return self._get_depend([depkind.value for depkind in DependencyKind], raw=True) @cache def get_depends(self) -> Dict[DependencyKind, List[Atom]]: depends = dict() for depkind in DependencyKind: - depend = self._get_depend([depkind]) + depend = self._get_depend([depkind.value]) depends[depkind] = depend return depends