Skip to content

Commit 0f10324

Browse files
fix: relax typing
1 parent 270068b commit 0f10324

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

  • snakemake_interface_software_deployment_plugins

snakemake_interface_software_deployment_plugins/__init__.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Generic
2-
31
__author__ = "Johannes Köster"
42
__copyright__ = "Copyright 2024, Johannes Köster"
53
__email__ = "johannes.koester@uni-due.de"
@@ -23,15 +21,11 @@
2321
Self,
2422
Tuple,
2523
Type,
26-
TypeVar,
2724
Union,
2825
Callable,
2926
)
3027
import subprocess as sp
3128

32-
from snakemake_interface_software_deployment_plugins.settings import (
33-
SoftwareDeploymentSettingsBase,
34-
)
3529
from snakemake_interface_common.exceptions import WorkflowError
3630

3731

@@ -63,8 +57,14 @@ def technical_init(self):
6357
self._obj_hash: Optional[int] = None
6458

6559
@classmethod
66-
def env_cls(cls):
67-
return cls.module().EnvBase
60+
def env_cls(cls) -> Type["EnvBase"]:
61+
try:
62+
return cls.module().EnvBase
63+
except AttributeError:
64+
raise AttributeError(
65+
"No class Env found next to EnvSpec class. "
66+
"Make sure to import or define it there."
67+
)
6868

6969
@classmethod
7070
@abstractmethod
@@ -168,28 +168,25 @@ def run(self, cmd: str, **kwargs) -> sp.CompletedProcess:
168168
return sp.run([self.executable] + self.args + [self.command_arg, cmd], **kwargs)
169169

170170

171-
TSettings = TypeVar("TSettings", bound="Optional[SoftwareDeploymentSettingsBase]")
172-
TEnvSpec = TypeVar("TEnvSpec", bound="EnvSpecBase")
173-
174-
175-
class EnvBase(ABC, Generic[TEnvSpec, TSettings]):
171+
class EnvBase(ABC):
176172
_cache: ClassVar[Dict[Tuple[Type["EnvBase"], Optional["EnvBase"]], Any]] = {}
177173

178174
def __init__(
179175
self,
180-
spec: TEnvSpec,
176+
spec,
181177
within: Optional["EnvBase"],
182-
settings: TSettings,
178+
settings,
183179
shell_executable: ShellExecutable,
184180
tempdir: Path,
185181
source_cache: Path,
186182
cache_prefix: Path,
187183
deployment_prefix: Path,
188184
pinfile_prefix: Path,
189185
):
190-
self.spec: TEnvSpec = spec
186+
# type annotation for spec and settings is left for implementing plugins
187+
self.spec = spec
191188
self.within = within
192-
self.settings: TSettings = settings
189+
self.settings = settings
193190
self.shell_executable = shell_executable
194191
self.tempdir = tempdir
195192
self.source_cache: Path = source_cache

0 commit comments

Comments
 (0)