Skip to content

Commit 17ad626

Browse files
committed
Consolidate builder env and env_vars methods
We just need one, which accepts varargs. And it should be named env to match appose-java.
1 parent da0f840 commit 17ad626

3 files changed

Lines changed: 7 additions & 27 deletions

File tree

src/appose/builder/__init__.py

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -171,26 +171,12 @@ def wrap(self, env_dir: str | Path) -> Environment:
171171
...
172172

173173
@abstractmethod
174-
def env(self, key: str, value: str) -> Builder:
174+
def env(self, **vars: dict[str, str]) -> Builder:
175175
"""
176-
Sets an environment variable to be passed to worker processes.
176+
Sets environment variables to be passed to worker processes.
177177
178178
Args:
179-
key: The environment variable name
180-
value: The environment variable value
181-
182-
Returns:
183-
This builder instance, for fluent-style programming
184-
"""
185-
...
186-
187-
@abstractmethod
188-
def env_vars(self, vars: dict[str, str]) -> Builder:
189-
"""
190-
Sets multiple environment variables to be passed to worker processes.
191-
192-
Args:
193-
vars: Map of environment variable names to values
179+
vars: Dictionary of environment variable names to values
194180
195181
Returns:
196182
This builder instance, for fluent-style programming
@@ -485,13 +471,8 @@ def wrap(self, env_dir: str | Path) -> Environment:
485471
self.base(env_path)
486472
return self.build()
487473

488-
def env(self, key: str, value: str) -> BaseBuilder:
489-
"""Set a single environment variable."""
490-
self.env_vars_dict[key] = value
491-
return self
492-
493-
def env_vars(self, vars: dict[str, str]) -> BaseBuilder:
494-
"""Set multiple environment variables."""
474+
def env(self, **vars: dict[str, str]) -> BaseBuilder:
475+
"""Set environment variables."""
495476
self.env_vars_dict.update(vars)
496477
return self
497478

@@ -763,7 +744,7 @@ def rebuild(self) -> Environment:
763744

764745
def _copy_config_to_delegate(self, delegate: Builder) -> None:
765746
"""Copy configuration from dynamic builder to delegate."""
766-
delegate.env_vars(self.env_vars_dict)
747+
delegate.env(**self.env_vars_dict)
767748
if self.env_name:
768749
delegate.set_name(self.env_name)
769750
if self.env_dir:

src/appose/environment.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ def service(
219219
:return: The newly created service.
220220
:see: groovy() To create a service for Groovy script execution.
221221
:see: python() To create a service for Python script execution.
222-
:raises IOError: If something goes wrong starting the worker process.
223222
"""
224223
if not exes:
225224
raise ValueError("No executable given")

tests/builder/test_simple.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_custom():
4646
"""
4747
env = (
4848
SimpleBuilder()
49-
.env("CUSTOM_VAR", "test_value") # Base Builder method
49+
.env(CUSTOM_VAR="test_value") # Base Builder method
5050
.inherit_running_java() # SimpleBuilder method
5151
.append_system_path() # SimpleBuilder method
5252
.build()

0 commit comments

Comments
 (0)