Skip to content

Commit 46e7609

Browse files
committed
Fixed bug where venv_config defined in command_group was getting ignored
Fixes #31 Signed-off-by: Pedro Algarvio <[email protected]>
1 parent 099f78b commit 46e7609

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

changelog/31.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed bug where `venv_config` defined in `command_group` was getting ignored

src/ptscripts/parser.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,10 +692,15 @@ def __call__(self, func, options, venv_config: VirtualEnvConfig | None = None):
692692
kwargs[name] = getattr(options, name)
693693

694694
bound = signature.bind_partial(*args, **kwargs)
695+
venv: VirtualEnv | None = None
695696
if venv_config:
696697
if "name" not in venv_config:
697698
venv_config["name"] = getattr(options, f"{self.name}_command")
698-
with VirtualEnv(ctx=self.context, **venv_config) as venv:
699+
venv = VirtualEnv(ctx=self.context, **venv_config)
700+
elif self.venv_config:
701+
venv = VirtualEnv(ctx=self.context, **self.venv_config)
702+
if venv:
703+
with venv:
699704
previous_venv = self.context.venv
700705
try:
701706
self.context.venv = venv

0 commit comments

Comments
 (0)