Skip to content

Commit

Permalink
Replace strings by constant
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Jan 10, 2022
1 parent f1c0d2a commit 25a35ac
Showing 1 changed file with 8 additions and 28 deletions.
36 changes: 8 additions & 28 deletions src/poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ def _version_nodot(version):
print('.'.join([str(s) for s in sys.version_info[:3]]))
"""

GET_PYTHON_VERSION_ONELINER = (
"\"import sys; print('.'.join([str(s) for s in sys.version_info[:3]]))\""
)

GET_SYS_PATH = """\
import json
import sys
Expand Down Expand Up @@ -483,14 +487,7 @@ def activate(self, python: str, io: "IO") -> "Env":
try:
python_version = decode(
subprocess.check_output(
list_to_shell_command(
[
python,
"-c",
"\"import sys; print('.'.join([str(s) for s in"
' sys.version_info[:3]]))"',
]
),
list_to_shell_command([python, "-c", GET_PYTHON_VERSION_ONELINER]),
shell=True,
)
)
Expand Down Expand Up @@ -730,14 +727,7 @@ def remove(self, python: str) -> "Env":
try:
python_version = decode(
subprocess.check_output(
list_to_shell_command(
[
python,
"-c",
"\"import sys; print('.'.join([str(s) for s in"
' sys.version_info[:3]]))"',
]
),
list_to_shell_command([python, "-c", GET_PYTHON_VERSION_ONELINER]),
shell=True,
)
)
Expand Down Expand Up @@ -807,12 +797,7 @@ def create_venv(
python_patch = decode(
subprocess.check_output(
list_to_shell_command(
[
executable,
"-c",
"\"import sys; print('.'.join([str(s) for s in"
' sys.version_info[:3]]))"',
]
[executable, "-c", GET_PYTHON_VERSION_ONELINER]
),
shell=True,
).strip()
Expand Down Expand Up @@ -862,12 +847,7 @@ def create_venv(
python_patch = decode(
subprocess.check_output(
list_to_shell_command(
[
python,
"-c",
"\"import sys; print('.'.join([str(s) for s in"
' sys.version_info[:3]]))"',
]
[python, "-c", GET_PYTHON_VERSION_ONELINER]
),
stderr=subprocess.STDOUT,
shell=True,
Expand Down

0 comments on commit 25a35ac

Please sign in to comment.