Skip to content

Commit

Permalink
feat: make use of Python in init and new command
Browse files Browse the repository at this point in the history
  • Loading branch information
finswimmer committed Mar 4, 2024
1 parent cff8bdb commit abb4d65
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
8 changes: 2 additions & 6 deletions src/poetry/console/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from poetry.console.commands.command import Command
from poetry.console.commands.env_command import EnvCommand
from poetry.utils.dependency_specification import RequirementsParser
from poetry.utils.env.python_manager import Python


if TYPE_CHECKING:
Expand Down Expand Up @@ -76,7 +77,6 @@ def handle(self) -> int:
from poetry.config.config import Config
from poetry.layouts import layout
from poetry.pyproject.toml import PyProjectTOML
from poetry.utils.env import EnvManager

project_path = Path.cwd()

Expand Down Expand Up @@ -158,11 +158,7 @@ def handle(self) -> int:
config = Config.create()
default_python = (
"^"
+ EnvManager.get_python_version(
precision=2,
prefer_active_python=config.get("virtualenvs.prefer-active-python"),
io=self.io,
).to_string()
+ Python.get_preferred_python(config, self.io).minor_version.to_string()
)

question = self.create_question(
Expand Down
12 changes: 4 additions & 8 deletions src/poetry/console/commands/new.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from cleo.helpers import option

from poetry.console.commands.command import Command
from poetry.utils.env.python_manager import Python


if TYPE_CHECKING:
Expand Down Expand Up @@ -40,7 +41,6 @@ def handle(self) -> int:

from poetry.config.config import Config
from poetry.layouts import layout
from poetry.utils.env import EnvManager

if self.io.input.option("directory"):
self.line_error(
Expand Down Expand Up @@ -79,13 +79,9 @@ def handle(self) -> int:
poetry_config = Config.create()
default_python = (
"^"
+ EnvManager.get_python_version(
precision=2,
prefer_active_python=poetry_config.get(
"virtualenvs.prefer-active-python"
),
io=self.io,
).to_string()
+ Python.get_preferred_python(
poetry_config, self.io
).minor_version.to_string()
)

layout_ = layout_cls(
Expand Down

0 comments on commit abb4d65

Please sign in to comment.