Skip to content

Commit

Permalink
Merge pull request #3764 from python-poetry/modern-core
Browse files Browse the repository at this point in the history
Update poetry-core
  • Loading branch information
sdispater authored Mar 19, 2021
2 parents c31864c + 47aa857 commit 757a113
Show file tree
Hide file tree
Showing 57 changed files with 196 additions and 192 deletions.
20 changes: 12 additions & 8 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion poetry/console/commands/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class AddCommand(InstallerCommand, InitCommand):
def handle(self) -> int:
from tomlkit import inline_table

from poetry.core.semver import parse_constraint
from poetry.core.semver.helpers import parse_constraint

packages = self.argument("name")
is_dev = self.option("dev")
Expand Down
2 changes: 1 addition & 1 deletion poetry/console/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BuildCommand(EnvCommand):
]

def handle(self) -> None:
from poetry.core.masonry import Builder
from poetry.core.masonry.builder import Builder

fmt = "all"
if self.option("format"):
Expand Down
7 changes: 3 additions & 4 deletions poetry/console/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
from cleo.helpers import argument
from cleo.helpers import option

from poetry.core.pyproject import PyProjectException
from poetry.core.toml.file import TOMLFile
from poetry.factory import Factory

from .command import Command


Expand Down Expand Up @@ -94,6 +90,9 @@ def handle(self) -> Optional[int]:
from pathlib import Path

from poetry.config.file_config_source import FileConfigSource
from poetry.core.pyproject.exceptions import PyProjectException
from poetry.core.toml.file import TOMLFile
from poetry.factory import Factory
from poetry.locations import CONFIG_DIR

config = Factory.create_config(self.io)
Expand Down
10 changes: 3 additions & 7 deletions poetry/console/commands/init.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import os
import re
import sys
Expand All @@ -17,9 +14,6 @@
from cleo.helpers import option
from tomlkit import inline_table

from poetry.core.pyproject import PyProjectException
from poetry.core.pyproject.toml import PyProjectTOML

from .command import Command
from .env_command import EnvCommand

Expand Down Expand Up @@ -70,6 +64,7 @@ def __init__(self) -> None:
def handle(self) -> int:
from pathlib import Path

from poetry.core.pyproject.toml import PyProjectTOML
from poetry.core.vcs.git import GitConfig
from poetry.layouts import layout
from poetry.utils.env import SystemEnv
Expand Down Expand Up @@ -384,6 +379,7 @@ def _find_best_version_for_package(
return package.pretty_name, selector.find_recommended_require_version(package)

def _parse_requirements(self, requirements: List[str]) -> List[Dict[str, str]]:
from poetry.core.pyproject.exceptions import PyProjectException
from poetry.puzzle.provider import Provider

result = []
Expand Down Expand Up @@ -534,7 +530,7 @@ def _validate_author(self, author: str, default: str) -> Optional[str]:
return author

def _validate_license(self, license: str) -> str:
from poetry.core.spdx import license_by_id
from poetry.core.spdx.helpers import license_by_id

if license:
license_by_id(license)
Expand Down
2 changes: 1 addition & 1 deletion poetry/console/commands/new.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class NewCommand(Command):
def handle(self) -> None:
from pathlib import Path

from poetry.core.semver import parse_constraint
from poetry.core.semver.helpers import parse_constraint
from poetry.core.vcs.git import GitConfig
from poetry.layouts import layout
from poetry.utils.env import SystemEnv
Expand Down
22 changes: 8 additions & 14 deletions poetry/console/commands/self/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,18 @@
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any
from urllib.error import HTTPError
from urllib.request import urlopen

from cleo.helpers import argument
from cleo.helpers import option

from poetry.console.exceptions import PoetrySimpleConsoleException
from poetry.core.packages import Dependency

from ..command import Command


if TYPE_CHECKING:
from poetry.core.packages import Package
from poetry.core.semver import Version


try:
from urllib.error import HTTPError
from urllib.request import urlopen
except ImportError:
from urllib2 import HTTPError
from urllib2 import urlopen
from poetry.core.packages.package import Package
from poetry.core.semver.version import Version


BIN = """# -*- coding: utf-8 -*-
Expand Down Expand Up @@ -89,7 +80,8 @@ def lib_backup(self) -> Path:

def handle(self) -> None:
from poetry.__version__ import __version__
from poetry.core.semver import Version
from poetry.core.packages.dependency import Dependency
from poetry.core.semver.version import Version
from poetry.repositories.pypi_repository import PyPiRepository

self._check_recommended_installation()
Expand Down Expand Up @@ -250,6 +242,8 @@ def process(self, *args: Any) -> str:
def _check_recommended_installation(self) -> None:
from pathlib import Path

from poetry.console.exceptions import PoetrySimpleConsoleException

current = Path(__file__)
try:
current.relative_to(self.home)
Expand Down
7 changes: 3 additions & 4 deletions poetry/console/commands/show.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from typing import TYPE_CHECKING
from typing import List
from typing import Optional
Expand All @@ -13,8 +12,8 @@
if TYPE_CHECKING:
from cleo.io.io import IO # noqa

from poetry.core.packages import Dependency
from poetry.core.packages import Package
from poetry.core.packages.dependency import Dependency
from poetry.core.packages.package import Package
from poetry.repositories import Repository
from poetry.repositories.installed_repository import InstalledRepository

Expand Down Expand Up @@ -408,7 +407,7 @@ def find_latest_package(
return selector.find_best_candidate(name, ">={}".format(package.pretty_version))

def get_update_status(self, latest: "Package", package: "Package") -> str:
from poetry.core.semver import parse_constraint
from poetry.core.semver.helpers import parse_constraint

if latest.full_pretty_version == package.full_pretty_version:
return "up-to-date"
Expand Down
4 changes: 2 additions & 2 deletions poetry/console/commands/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


if TYPE_CHECKING:
from poetry.core.semver import Version
from poetry.core.semver.version import Version


class VersionCommand(Command):
Expand Down Expand Up @@ -79,7 +79,7 @@ def handle(self) -> None:
)

def increment_version(self, version: str, rule: str) -> "Version":
from poetry.core.semver import Version
from poetry.core.semver.version import Version

try:
version = Version.parse(version)
Expand Down
10 changes: 5 additions & 5 deletions poetry/inspection/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import pkginfo

from poetry.core.factory import Factory
from poetry.core.packages import Package
from poetry.core.packages import ProjectPackage
from poetry.core.packages import dependency_from_pep_508
from poetry.core.packages.dependency import Dependency
from poetry.core.packages.package import Package
from poetry.core.packages.project_package import ProjectPackage
from poetry.core.pyproject.toml import PyProjectTOML
from poetry.core.utils.helpers import parse_requires
from poetry.core.utils.helpers import temporary_directory
Expand Down Expand Up @@ -170,11 +170,11 @@ def to_package(
for req in self.requires_dist or []:
try:
# Attempt to parse the PEP-508 requirement string
dependency = dependency_from_pep_508(req, relative_to=root_dir)
dependency = Dependency.create_from_pep_508(req, relative_to=root_dir)
except InvalidMarker:
# Invalid marker, We strip the markers hoping for the best
req = req.split(";")[0]
dependency = dependency_from_pep_508(req, relative_to=root_dir)
dependency = Dependency.create_from_pep_508(req, relative_to=root_dir)
except ValueError:
# Likely unable to parse constraint so we skip it
self._log(
Expand Down
2 changes: 1 addition & 1 deletion poetry/installation/base_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


if TYPE_CHECKING:
from poetry.core.packages import Package
from poetry.core.packages.package import Package


class BaseInstaller:
Expand Down
2 changes: 1 addition & 1 deletion poetry/installation/noop_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


if TYPE_CHECKING:
from poetry.core.packages import Package
from poetry.core.packages.package import Package


class NoopInstaller(BaseInstaller):
Expand Down
2 changes: 1 addition & 1 deletion poetry/installation/operations/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


if TYPE_CHECKING:
from poetry.core.packages import Package
from poetry.core.packages.package import Package


class Install(Operation):
Expand Down
4 changes: 1 addition & 3 deletions poetry/installation/operations/operation.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-

from typing import TYPE_CHECKING
from typing import Optional


if TYPE_CHECKING:
from poetry.core.packages import Package
from poetry.core.packages.package import Package


class Operation(object):
Expand Down
2 changes: 1 addition & 1 deletion poetry/installation/operations/uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


if TYPE_CHECKING:
from poetry.core.packages import Package
from poetry.core.packages.package import Package


class Uninstall(Operation):
Expand Down
2 changes: 1 addition & 1 deletion poetry/installation/operations/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


if TYPE_CHECKING:
from poetry.core.packages import Package
from poetry.core.packages.package import Package


class Update(Operation):
Expand Down
6 changes: 3 additions & 3 deletions poetry/installation/pip_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


if TYPE_CHECKING:
from poetry.core.packages import Package
from poetry.core.packages.package import Package


class PipInstaller(BaseInstaller):
Expand Down Expand Up @@ -242,8 +242,8 @@ def install_directory(self, package: "Package") -> Union[str, int]:
return self.run(*args)

def install_git(self, package: "Package") -> None:
from poetry.core.packages import Package
from poetry.core.vcs import Git
from poetry.core.packages.package import Package
from poetry.core.vcs.git import Git

src_dir = self._env.path / "src" / package.name
if src_dir.exists():
Expand Down
2 changes: 1 addition & 1 deletion poetry/mixology/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


if TYPE_CHECKING:
from poetry.core.packages import ProjectPackage
from poetry.core.packages.project_package import ProjectPackage
from poetry.packages import DependencyPackage
from poetry.puzzle.provider import Provider

Expand Down
4 changes: 2 additions & 2 deletions poetry/mixology/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@


if TYPE_CHECKING:
from poetry.core.packages import Dependency
from poetry.core.packages import Package
from poetry.core.packages.dependency import Dependency
from poetry.core.packages.package import Package

from .incompatibility import Incompatibility

Expand Down
2 changes: 1 addition & 1 deletion poetry/mixology/failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Optional
from typing import Tuple

from poetry.core.semver import parse_constraint
from poetry.core.semver.helpers import parse_constraint

from .incompatibility import Incompatibility
from .incompatibility_cause import ConflictCause
Expand Down
4 changes: 2 additions & 2 deletions poetry/mixology/partial_solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@


if TYPE_CHECKING:
from poetry.core.packages import Dependency
from poetry.core.packages import Package
from poetry.core.packages.dependency import Dependency
from poetry.core.packages.package import Package


class PartialSolution:
Expand Down
4 changes: 2 additions & 2 deletions poetry/mixology/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@


if TYPE_CHECKING:
from poetry.core.packages import Package
from poetry.core.packages import ProjectPackage
from poetry.core.packages.package import Package
from poetry.core.packages.project_package import ProjectPackage


class SolverResult:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class PythonRequirementSolution(Solution):
def __init__(self, exception: "PackageNotFoundCause") -> None:
from poetry.core.semver import parse_constraint
from poetry.core.semver.helpers import parse_constraint
from poetry.mixology.incompatibility_cause import PythonCause

self._title = "Check your dependencies Python requirement."
Expand Down
Loading

0 comments on commit 757a113

Please sign in to comment.