Skip to content

Commit 7212b70

Browse files
committed
Fix typing errors
1 parent e165d28 commit 7212b70

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/appose/builder/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __init__(
5858
message = f"{noun} {verb}"
5959
super().__init__(message)
6060
self.builder: Builder | None = builder
61-
self.__cause__: Exception | None = cause
61+
self.__cause__ = cause
6262

6363

6464
class Builder(ABC):
@@ -441,7 +441,7 @@ def __init__(self):
441441
def delete(self) -> None:
442442
"""Default implementation: delete env_dir if it exists."""
443443
dir_path = self._env_dir
444-
if dir_path.exists():
444+
if dir_path is not None and dir_path.exists():
445445
shutil.rmtree(dir_path)
446446

447447
def wrap(self, env_dir: str | Path) -> Environment:
@@ -856,7 +856,7 @@ def env_type(env_dir: str | Path) -> str | None:
856856
The environment type name (e.g., "pixi", "mamba", "uv"), or None if not a known environment
857857
"""
858858
factory = find_factory_for_wrapping(env_dir)
859-
return factory.name() if factory else None
859+
return factory.env_type() if factory else None
860860

861861

862862
def _discover_factories() -> list[BuilderFactory]:

src/appose/environment.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,14 @@ def env_vars(self) -> dict[str, str]:
6464
# Default implementation - subclasses should override
6565
return {}
6666

67-
def builder(self) -> Builder | None:
67+
def builder(self) -> Builder:
6868
"""
6969
Get the builder that created this environment.
7070
7171
Returns:
7272
The builder instance, or None if not created via a builder
7373
"""
74-
# Default implementation - subclasses should override
75-
return None
74+
...
7675

7776
def type(self) -> str:
7877
"""
@@ -191,7 +190,7 @@ def java(
191190
jvm_args: list[str] | None = None,
192191
) -> Service:
193192
# Collect classpath elements into a set, to avoid duplicate entries.
194-
cp: dict[str] = {} # NB: Use dict instead of set to maintain insertion order.
193+
cp: dict[str, str | None] = {} # NB: Use dict to maintain insertion order.
195194

196195
# TODO: Ensure that the classpath includes Appose and its dependencies.
197196

src/appose/python_worker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
class Task:
3333
def __init__(
3434
self,
35-
worker: "Worker" | None = None,
35+
worker: "Worker | None" = None,
3636
uuid: str | None = None,
3737
script: str | None = None,
3838
inputs: Args | None = None,
@@ -100,7 +100,7 @@ def _run(self) -> None:
100100
# which we evaluate instead to get its return value.
101101
# Credit: https://stackoverflow.com/a/39381428/1207769
102102

103-
block = ast.parse(self._script, mode="exec")
103+
block = ast.parse(self._script or "", mode="exec")
104104
last = None
105105
if (
106106
len(block.body) > 0

0 commit comments

Comments
 (0)