Skip to content

Commit

Permalink
Misc fixes (#9283)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Apr 8, 2024
1 parent f8a6a94 commit 29d3c5f
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 46 deletions.
19 changes: 10 additions & 9 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 @@ -33,7 +33,7 @@ python = "^3.8"

poetry-core = "1.9.0"
poetry-plugin-export = "^1.7.0"
build = "^1.1.1"
build = "^1.2.1"
cachecontrol = { version = "^0.14.0", extras = ["filecache"] }
cleo = "^2.1.0"
dulwich = "^0.21.2"
Expand Down
12 changes: 1 addition & 11 deletions src/poetry/__version__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from poetry.utils._compat import metadata


if TYPE_CHECKING:
from collections.abc import Callable


# The metadata.version that we import for Python 3.7 is untyped, work around
# that.
version: Callable[[str], str] = metadata.version

__version__ = version("poetry")
__version__ = metadata.version("poetry")
2 changes: 1 addition & 1 deletion src/poetry/console/logging/formatters/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


class Formatter:
def format(self, record: str) -> str:
def format(self, msg: str) -> str:
raise NotImplementedError()
4 changes: 3 additions & 1 deletion src/poetry/installation/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@


if TYPE_CHECKING:
from build import DistributionType

from poetry.repositories import RepositoryPool
from poetry.utils.cache import ArtifactCache
from poetry.utils.env import Env
Expand Down Expand Up @@ -48,7 +50,7 @@ def _prepare(
) -> Path:
from subprocess import CalledProcessError

distribution = "wheel" if not editable else "editable"
distribution: DistributionType = "editable" if editable else "wheel" # type: ignore[assignment]
error: Exception | None = None

try:
Expand Down
4 changes: 2 additions & 2 deletions src/poetry/json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import fastjsonschema

from fastjsonschema.exceptions import JsonSchemaException
from fastjsonschema.exceptions import JsonSchemaValueException
from poetry.core.json import SCHEMA_DIR as CORE_SCHEMA_DIR


Expand All @@ -27,7 +27,7 @@ def validate_object(obj: dict[str, Any]) -> list[str]:
errors = []
try:
validate(obj)
except JsonSchemaException as e:
except JsonSchemaValueException as e:
errors = [e.message]

core_schema = json.loads(
Expand Down
5 changes: 3 additions & 2 deletions src/poetry/puzzle/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
if TYPE_CHECKING:
from collections.abc import Collection
from collections.abc import Iterator
from collections.abc import Sequence

from cleo.io.io import IO
from packaging.utils import NormalizedName
Expand Down Expand Up @@ -207,7 +208,7 @@ def __init__(self, id: DFSNodeID, name: str, base_name: str) -> None:
self.name = name
self.base_name = base_name

def reachable(self: T) -> list[T]:
def reachable(self: T) -> Sequence[T]:
return []

def visit(self, parents: list[PackageNode]) -> None:
Expand Down Expand Up @@ -284,7 +285,7 @@ def __init__(
package.name,
)

def reachable(self) -> list[PackageNode]:
def reachable(self) -> Sequence[PackageNode]:
children: list[PackageNode] = []

for dependency in self.package.all_requires:
Expand Down
3 changes: 2 additions & 1 deletion src/poetry/utils/isolated_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
if TYPE_CHECKING:
from pathlib import Path

from build import DistributionType
from build import ProjectBuilder

from poetry.repositories import RepositoryPool
Expand Down Expand Up @@ -107,7 +108,7 @@ def install(self, requirements: Collection[str]) -> None:
@contextmanager
def isolated_builder(
source: Path,
distribution: str = "wheel",
distribution: DistributionType = "wheel",
python_executable: Path | None = None,
pool: RepositoryPool | None = None,
) -> Iterator[ProjectBuilder]:
Expand Down
2 changes: 1 addition & 1 deletion tests/installation/test_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@ def test_run_install_duplicate_dependencies_different_constraints_with_lock(
assert installer.executor.removals_count == 0


def test_run_update_uninstalls_after_removal_transient_dependency(
def test_run_update_uninstalls_after_removal_transitive_dependency(
installer: Installer,
locker: Locker,
repo: Repository,
Expand Down
8 changes: 4 additions & 4 deletions tests/puzzle/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,7 @@ def test_solver_duplicate_dependencies_ignore_overrides_with_empty_marker_inters
solver: Solver, repo: Repository, package: ProjectPackage
) -> None:
"""
Empty intersection between top level dependency and transient dependency.
Empty intersection between top level dependency and transitive dependency.
"""
package.add_dependency(Factory.create_dependency("A", {"version": "1.0"}))
package.add_dependency(
Expand Down Expand Up @@ -3307,7 +3307,7 @@ def test_solver_chooses_direct_dependency_from_explicit_if_explicit(
assert ops[0].package.source_url is None


def test_solver_ignores_explicit_repo_for_transient_dependencies(
def test_solver_ignores_explicit_repo_for_transitive_dependencies(
package: ProjectPackage,
io: NullIO,
legacy_repository: LegacyRepository,
Expand Down Expand Up @@ -4358,7 +4358,7 @@ def test_solver_does_not_update_ref_of_locked_vcs_package(
Factory.create_dependency("demo", {"git": "https://github.com/demo/demo.git"})
)

# transient dependencies of demo
# transitive dependencies of demo
pendulum = get_package("pendulum", "2.0.3")
repo.add_package(pendulum)

Expand Down Expand Up @@ -4404,7 +4404,7 @@ def test_solver_does_not_fetch_locked_vcs_package_with_ref(
Factory.create_dependency("demo", {"git": "https://github.com/demo/demo.git"})
)

# transient dependencies of demo
# transitive dependencies of demo
pendulum = get_package("pendulum", "2.0.3")
repo.add_package(pendulum)

Expand Down
24 changes: 12 additions & 12 deletions tests/repositories/fixtures/python_hosted.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@
@pytest.fixture
def mock_files_python_hosted_factory(http: type[httpretty]) -> PythonHostedFileMocker:
def factory(
distribution_locations: list[Path], metadata_locations: list[Path] | None = None
distribution_locations: list[Path], metadata_locations: list[Path]
) -> None:
def file_callback(
request: HTTPrettyRequest, uri: str, headers: dict[str, Any]
) -> list[int | dict[str, Any] | bytes | str]:
name = Path(urlparse(uri).path).name

if metadata_locations and name.endswith(".metadata"):
for location in metadata_locations:
fixture = location / name
if fixture.exists():
return [200, headers, fixture.read_text()]
else:
for location in distribution_locations:
fixture = location / name
if fixture.exists():
return [200, headers, fixture.read_bytes()]
locations = (
metadata_locations
if name.endswith(".metadata")
else distribution_locations
)

for location in locations:
fixture = location / name
if fixture.exists():
return [200, headers, fixture.read_bytes()]

return [404, headers, b"Not Found"]

Expand Down Expand Up @@ -68,7 +68,7 @@ def mock_file_callback(
def mock_files_python_hosted(
mock_files_python_hosted_factory: PythonHostedFileMocker,
package_distribution_locations: list[Path],
package_metadata_locations: list[Path] | None,
package_metadata_locations: list[Path],
) -> Iterator[None]:
mock_files_python_hosted_factory(
distribution_locations=package_distribution_locations,
Expand Down
2 changes: 1 addition & 1 deletion tests/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class PythonHostedFileMocker(Protocol):
def __call__(
self,
distribution_locations: list[Path],
metadata_locations: list[Path] | None = None,
metadata_locations: list[Path],
) -> None: ...


Expand Down

0 comments on commit 29d3c5f

Please sign in to comment.