Skip to content

Commit

Permalink
dependencies.py: use Enum rather than StrEnum for DependencyKind
Browse files Browse the repository at this point in the history
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).

Fixes: 78464ec
Signed-off-by: John Turner <[email protected]>
Closes: #46
Signed-off-by: Sam James <[email protected]>
  • Loading branch information
Jturnerusa authored and thesamesam committed Mar 7, 2024
1 parent f410ba4 commit 5c8f8d7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pym/gentoolkit/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,7 +28,7 @@
# =======


class DependencyKind(StrEnum):
class DependencyKind(Enum):
DEPEND = "DEPEND"
RDEPEND = "RDEPEND"
BDEPEND = "BDEPEND"
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 5c8f8d7

Please sign in to comment.