Skip to content

Commit

Permalink
Specify DataModule as return type
Browse files Browse the repository at this point in the history
  • Loading branch information
olejandro committed Nov 25, 2024
1 parent c293838 commit c639dfe
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions xl2times/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class DataModule(str, Enum):
trade = "SuppXLS/Trades/ScenTrade_*.*"

@classmethod
def _find_type_(cls, path: str) -> Enum | None:
def determine_type(cls, path: str) -> "DataModule | None":
for data_module in cls:
if any(
PurePath(path.lower()).match(pattern.lower().strip())
Expand All @@ -95,15 +95,15 @@ def _find_type_(cls, path: str) -> Enum | None:

@classmethod
def module_type(cls, path: str) -> str | None:
module_type = cls._find_type_(path)
module_type = cls.determine_type(path)
if module_type:
return module_type.name
else:
return None

@classmethod
def submodule(cls, path: str) -> str | None:
match cls._find_type_(path):
match cls.determine_type(path):
case DataModule.base | DataModule.subres:
if PurePath(path.lower()).match("*_trans.*"):
return "trans"
Expand All @@ -116,7 +116,7 @@ def submodule(cls, path: str) -> str | None:

@classmethod
def module_name(cls, path: str) -> str | None:
module_type = cls._find_type_(path)
module_type = cls.determine_type(path)
match module_type:
case DataModule.base | DataModule.sets | DataModule.lma | DataModule.demand | DataModule.trade | DataModule.syssettings:
return module_type.name
Expand Down

0 comments on commit c639dfe

Please sign in to comment.