Skip to content

Commit ab12e13

Browse files
authored
improved error message for env activate (#10255)
1 parent c4ec1b0 commit ab12e13

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/poetry/console/commands/env/activate.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,20 @@ def handle(self) -> int:
2727

2828
env = EnvManager(self.poetry).get()
2929

30-
if command := self._get_activate_command(env):
31-
self.line(command)
32-
return 0
33-
else:
34-
raise ShellNotSupportedError(
35-
"Discovered shell doesn't have an activator in virtual environment"
36-
)
37-
38-
def _get_activate_command(self, env: Env) -> str:
3930
try:
4031
shell, _ = shellingham.detect_shell()
4132
except shellingham.ShellDetectionFailure:
4233
shell = ""
34+
35+
if command := self._get_activate_command(env, shell):
36+
self.line(command)
37+
return 0
38+
39+
raise ShellNotSupportedError(
40+
f"Discovered shell '{shell}' doesn't have an activator in virtual environment"
41+
)
42+
43+
def _get_activate_command(self, env: Env, shell: str) -> str:
4344
if shell == "fish":
4445
command, filename = "source", "activate.fish"
4546
elif shell == "nu":

0 commit comments

Comments
 (0)