Skip to content

Commit

Permalink
Align with core exceptions name changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Secrus committed Oct 3, 2024
1 parent d152453 commit 29326dc
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 35 deletions.
16 changes: 8 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 pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Changelog = "https://python-poetry.org/history/"
[tool.poetry.dependencies]
python = "^3.8"

poetry-core = { git = "https://github.com/python-poetry/poetry-core.git", branch = "main" }
poetry-core = { git = "https://github.com/secrus/poetry-core.git", branch = "error-names" }
poetry-plugin-export = "^1.8.0"
build = "^1.2.1"
cachecontrol = { version = "^0.14.0", extras = ["filecache"] }
Expand Down
4 changes: 2 additions & 2 deletions src/poetry/console/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def unique_config_values(self) -> dict[str, tuple[Any, Any]]:
def handle(self) -> int:
from pathlib import Path

from poetry.core.pyproject.exceptions import PyProjectException
from poetry.core.pyproject.exceptions import PyProjectError

from poetry.config.config import Config
from poetry.config.file_config_source import FileConfigSource
Expand All @@ -105,7 +105,7 @@ def handle(self) -> int:
local_config_file = TOMLFile(self.poetry.file.path.parent / "poetry.toml")
if local_config_file.exists():
config.merge(local_config_file.read())
except (RuntimeError, PyProjectException):
except (RuntimeError, PyProjectError):
local_config_file = TOMLFile(Path.cwd() / "poetry.toml")

if self.option("local"):
Expand Down
4 changes: 2 additions & 2 deletions src/poetry/console/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,12 +459,12 @@ def _find_best_version_for_package(
return package.pretty_name, f"^{version.to_string()}"

def _parse_requirements(self, requirements: list[str]) -> list[dict[str, Any]]:
from poetry.core.pyproject.exceptions import PyProjectException
from poetry.core.pyproject.exceptions import PyProjectError

try:
cwd = self.poetry.file.path.parent
artifact_cache = self.poetry.pool.artifact_cache
except (PyProjectException, RuntimeError):
except (PyProjectError, RuntimeError):
cwd = Path.cwd()
artifact_cache = self._get_pool().artifact_cache

Expand Down
4 changes: 2 additions & 2 deletions src/poetry/console/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def activated_groups(self) -> set[str]:
return super().activated_groups

def handle(self) -> int:
from poetry.core.masonry.utils.module import ModuleOrPackageNotFound
from poetry.core.masonry.utils.module import ModuleOrPackageNotFoundError

from poetry.masonry.builders.editable import EditableBuilder

Expand Down Expand Up @@ -189,7 +189,7 @@ def handle(self) -> int:
try:
builder = EditableBuilder(self.poetry, self.env, self.io)
builder.build()
except (ModuleOrPackageNotFound, FileNotFoundError) as e:
except (ModuleOrPackageNotFoundError, FileNotFoundError) as e:
# This is likely due to the fact that the project is an application
# not following the structure expected by Poetry.
# No need for an editable install in this case.
Expand Down
4 changes: 2 additions & 2 deletions src/poetry/console/commands/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from cleo.helpers import argument
from cleo.helpers import option
from poetry.core.version.exceptions import InvalidVersion
from poetry.core.version.exceptions import InvalidVersionError
from tomlkit.toml_document import TOMLDocument

from poetry.console.commands.command import Command
Expand Down Expand Up @@ -96,7 +96,7 @@ def increment_version(

try:
parsed = Version.parse(version)
except InvalidVersion:
except InvalidVersionError:
raise ValueError("The project's version doesn't seem to follow semver")

if rule in {"major", "premajor"}:
Expand Down
8 changes: 4 additions & 4 deletions src/poetry/inspection/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
from poetry.core.pyproject.toml import PyProjectTOML
from poetry.core.utils.helpers import parse_requires
from poetry.core.utils.helpers import temporary_directory
from poetry.core.version.markers import InvalidMarker
from poetry.core.version.requirements import InvalidRequirement
from poetry.core.version.markers import InvalidMarkerError
from poetry.core.version.requirements import InvalidRequirementError

from poetry.utils.helpers import extractall
from poetry.utils.isolated_build import isolated_builder
Expand Down Expand Up @@ -178,7 +178,7 @@ def to_package(
try:
# Attempt to parse the PEP-508 requirement string
dependency = Dependency.create_from_pep_508(req, relative_to=root_dir)
except InvalidMarker:
except InvalidMarkerError:
# Invalid marker, We strip the markers hoping for the best
logger.warning(
"Stripping invalid marker (%s) found in %s-%s dependencies",
Expand All @@ -188,7 +188,7 @@ def to_package(
)
req = req.split(";")[0]
dependency = Dependency.create_from_pep_508(req, relative_to=root_dir)
except InvalidRequirement:
except InvalidRequirementError:
# Unable to parse requirement so we skip it
logger.warning(
"Invalid requirement (%s) found in %s-%s dependencies, skipping",
Expand Down
4 changes: 2 additions & 2 deletions src/poetry/packages/locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from poetry.core.constraints.version import parse_constraint
from poetry.core.packages.dependency import Dependency
from poetry.core.packages.package import Package
from poetry.core.version.requirements import InvalidRequirement
from poetry.core.version.requirements import InvalidRequirementError
from tomlkit import array
from tomlkit import comment
from tomlkit import document
Expand Down Expand Up @@ -194,7 +194,7 @@ def locked_repository(self) -> LockfileRepository:
for dep in deps:
try:
dependency = Dependency.create_from_pep_508(dep)
except InvalidRequirement:
except InvalidRequirementError:
# handle lock files with invalid PEP 508
m = re.match(r"^(.+?)(?:\[(.+?)])?(?:\s+\((.+)\))?$", dep)
if not m:
Expand Down
4 changes: 2 additions & 2 deletions src/poetry/repositories/link_sources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from poetry.core.constraints.version import Version
from poetry.core.packages.package import Package
from poetry.core.version.exceptions import InvalidVersion
from poetry.core.version.exceptions import InvalidVersionError

from poetry.utils.patterns import sdist_file_re
from poetry.utils.patterns import wheel_file_re
Expand Down Expand Up @@ -86,7 +86,7 @@ def link_package_data(cls, link: Link) -> Package | None:
if version_string:
try:
version = Version.parse(version_string)
except InvalidVersion:
except InvalidVersionError:
logger.debug(
"Skipping url (%s) due to invalid version (%s)", link.url, version
)
Expand Down
4 changes: 2 additions & 2 deletions src/poetry/repositories/pypi_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from cachecontrol.controller import logger as cache_control_logger
from poetry.core.packages.package import Package
from poetry.core.packages.utils.link import Link
from poetry.core.version.exceptions import InvalidVersion
from poetry.core.version.exceptions import InvalidVersionError

from poetry.repositories.exceptions import PackageNotFoundError
from poetry.repositories.http_repository import HTTPRepository
Expand Down Expand Up @@ -64,7 +64,7 @@ def search(self, query: str) -> list[Package]:
package = Package(result.name, result.version)
package.description = result.description.strip()
results.append(package)
except InvalidVersion:
except InvalidVersionError:
self._log(
f'Unable to parse version "{result.version}" for the'
f" {result.name} package, skipping",
Expand Down
4 changes: 2 additions & 2 deletions src/poetry/toml/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

from poetry.core.exceptions import PoetryCoreException
from poetry.core.exceptions import PoetryCoreError
from tomlkit.exceptions import TOMLKitError


class TOMLError(TOMLKitError, PoetryCoreException):
class TOMLError(TOMLKitError, PoetryCoreError):
pass
4 changes: 2 additions & 2 deletions tests/console/commands/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pytest

from deepdiff import DeepDiff
from poetry.core.pyproject.exceptions import PyProjectException
from poetry.core.pyproject.exceptions import PyProjectError

from poetry.config.config_source import ConfigSource
from poetry.console.commands.install import InstallCommand
Expand Down Expand Up @@ -39,7 +39,7 @@ def test_show_config_with_local_config_file_empty(
) -> None:
mocker.patch(
"poetry.factory.Factory.create_poetry",
side_effect=PyProjectException("[tool.poetry] section not found"),
side_effect=PyProjectError("[tool.poetry] section not found"),
)
tester.execute()

Expand Down
4 changes: 2 additions & 2 deletions tests/console/commands/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from poetry.core.masonry.utils.module import ModuleOrPackageNotFound
from poetry.core.masonry.utils.module import ModuleOrPackageNotFoundError
from poetry.core.packages.dependency_group import MAIN_GROUP

from poetry.console.commands.installer_command import InstallerCommand
Expand Down Expand Up @@ -128,7 +128,7 @@ def test_group_options_are_passed_to_the_installer(
mocker.patch.object(tester.command.installer, "run", return_value=0)
editable_builder_mock = mocker.patch(
"poetry.masonry.builders.editable.EditableBuilder",
side_effect=ModuleOrPackageNotFound(),
side_effect=ModuleOrPackageNotFoundError(),
)

if not with_root:
Expand Down
4 changes: 2 additions & 2 deletions tests/pyproject/test_pyproject_toml_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

from poetry.core.exceptions import PoetryCoreException
from poetry.core.exceptions import PoetryCoreError

from poetry.toml import TOMLFile

Expand All @@ -17,7 +17,7 @@ def test_pyproject_toml_file_invalid(pyproject_toml: Path) -> None:
with pyproject_toml.open(mode="a", encoding="utf-8") as f:
f.write("<<<<<<<<<<<")

with pytest.raises(PoetryCoreException) as excval:
with pytest.raises(PoetryCoreError) as excval:
_ = TOMLFile(pyproject_toml).read()

assert f"Invalid TOML file {pyproject_toml.as_posix()}" in str(excval.value)
Expand Down

0 comments on commit 29326dc

Please sign in to comment.