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).
  • Loading branch information
Jturnerusa committed Mar 6, 2024
1 parent f410ba4 commit ceaa7d9
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 ceaa7d9

Please sign in to comment.