Skip to content

Commit

Permalink
Merge branch 'master' into fix-requests-auto-decode-gzip
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering authored Dec 20, 2023
2 parents 82ce531 + 5ddc81c commit 58221a9
Show file tree
Hide file tree
Showing 18 changed files with 277 additions and 312 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
- id: check-docstring-first

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.11.0
rev: 23.12.0
hooks:
- id: black
exclude: tests/([^/]*/)*fixtures/
Expand All @@ -32,6 +32,6 @@ repos:
- id: validate_manifest

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.7
rev: v0.1.8
hooks:
- id: ruff
141 changes: 65 additions & 76 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ tomlkit = ">=0.11.4,<1.0.0"
# trove-classifiers uses calver, so version is unclamped
trove-classifiers = ">=2022.5.19"
virtualenv = "^20.23.0"
xattr = { version = "^0.10.0", markers = "sys_platform == 'darwin'" }
xattr = { version = "^1.0.0", markers = "sys_platform == 'darwin'" }

[tool.poetry.group.dev.dependencies]
pre-commit = ">=2.10"
Expand Down
12 changes: 5 additions & 7 deletions src/poetry/installation/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ class ChefBuildError(ChefError): ...

class ChefInstallError(ChefError):
def __init__(self, requirements: Collection[str], output: str, error: str) -> None:
message = "\n\n".join(
(
f"Failed to install {', '.join(requirements)}.",
f"Output:\n{output}",
f"Error:\n{error}",
)
)
message = "\n\n".join((
f"Failed to install {', '.join(requirements)}.",
f"Output:\n{output}",
f"Error:\n{error}",
))
super().__init__(message)
self._requirements = requirements

Expand Down
18 changes: 9 additions & 9 deletions src/poetry/mixology/incompatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ def _try_requires_both(
if this_positive.dependency != other_positive.dependency:
return None

this_negatives = " or ".join([
self._terse(term) for term in self._terms if not term.is_positive()
])
this_negatives = " or ".join(
[self._terse(term) for term in self._terms if not term.is_positive()]
)

other_negatives = " or ".join([
self._terse(term) for term in other.terms if not term.is_positive()
])
other_negatives = " or ".join(
[self._terse(term) for term in other.terms if not term.is_positive()]
)

buffer = [self._terse(this_positive, allow_every=True) + " "]
is_dependency = isinstance(self.cause, DependencyCause) and isinstance(
Expand Down Expand Up @@ -355,9 +355,9 @@ def _try_requires_through(
buffer.append("requires ")

buffer.append(
" or ".join([
self._terse(term) for term in latter.terms if not term.is_positive()
])
" or ".join(
[self._terse(term) for term in latter.terms if not term.is_positive()]
)
)

if latter_line is not None:
Expand Down
10 changes: 4 additions & 6 deletions src/poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,10 @@ def _search_for_file(self, dependency: FileDependency) -> Package:
if dependency.base is not None:
package.root_dir = dependency.base

package.files = [
{
"file": dependency.path.name,
"hash": "sha256:" + get_file_hash(dependency.full_path),
}
]
package.files = [{
"file": dependency.path.name,
"hash": "sha256:" + get_file_hash(dependency.full_path),
}]

return package

Expand Down
14 changes: 8 additions & 6 deletions src/poetry/utils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ def activate(self, env: VirtualEnv) -> int | None:
cmd = f"{self._get_source_command()} {shlex.quote(str(activate_path))}"

with env.temp_environ():
args = ["-e", cmd] if self._name == "nu" else ["-i"]
if self._name == "nu":
args = ["-e", cmd]
elif self._name == "fish":
args = ["-i", "--init-command", cmd]
else:
args = ["-i"]

c = pexpect.spawn(
self._path, args, dimensions=(terminal.lines, terminal.columns)
Expand All @@ -120,14 +125,11 @@ def activate(self, env: VirtualEnv) -> int | None:
c.sendline(f"emulate bash -c '. {shlex.quote(str(activate_path))}'")
elif self._name == "xonsh":
c.sendline(f"vox activate {shlex.quote(str(env.path))}")
elif self._name == "nu":
# If this is nu, we don't want to send the activation command to the
elif self._name in ["nu", "fish"]:
# If this is nu or fish, we don't want to send the activation command to the
# command line since we already ran it via the shell's invocation.
pass
else:
if self._name in ["fish"]:
# Under fish, "\r" should be sent explicitly
cmd += "\r"
c.sendline(cmd)

def resize(sig: Any, data: Any) -> None:
Expand Down
36 changes: 15 additions & 21 deletions tests/console/commands/self/test_show_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,10 @@ def mock_metadata_entry_points(
@pytest.mark.parametrize("entry_point_name", ["poetry-plugin", "not-package-name"])
@pytest.mark.parametrize(
"entry_point_values_by_group",
[
{
ApplicationPlugin.group: ["FirstApplicationPlugin"],
Plugin.group: ["FirstPlugin"],
}
],
[{
ApplicationPlugin.group: ["FirstApplicationPlugin"],
Plugin.group: ["FirstPlugin"],
}],
)
def test_show_displays_installed_plugins(
app: PoetryTestApplication,
Expand All @@ -170,15 +168,13 @@ def test_show_displays_installed_plugins(

@pytest.mark.parametrize(
"entry_point_values_by_group",
[
{
ApplicationPlugin.group: [
"FirstApplicationPlugin",
"SecondApplicationPlugin",
],
Plugin.group: ["FirstPlugin", "SecondPlugin"],
}
],
[{
ApplicationPlugin.group: [
"FirstApplicationPlugin",
"SecondApplicationPlugin",
],
Plugin.group: ["FirstPlugin", "SecondPlugin"],
}],
)
def test_show_displays_installed_plugins_with_multiple_plugins(
app: PoetryTestApplication,
Expand All @@ -199,12 +195,10 @@ def test_show_displays_installed_plugins_with_multiple_plugins(
)
@pytest.mark.parametrize(
"entry_point_values_by_group",
[
{
ApplicationPlugin.group: ["FirstApplicationPlugin"],
Plugin.group: ["FirstPlugin"],
}
],
[{
ApplicationPlugin.group: ["FirstApplicationPlugin"],
Plugin.group: ["FirstPlugin"],
}],
)
def test_show_displays_installed_plugins_with_dependencies(
app: PoetryTestApplication,
Expand Down
28 changes: 13 additions & 15 deletions tests/console/commands/test_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -2026,21 +2026,19 @@ def test_url_dependency_is_not_outdated_by_repository_package(

assert isinstance(poetry.locker, TestLocker)
poetry.locker.mock_lock_data({
"package": [
{
"name": "demo",
"version": "0.1.0",
"description": "Demo package",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
"source": {
"type": "url",
"url": demo_url,
},
}
],
"package": [{
"name": "demo",
"version": "0.1.0",
"description": "Demo package",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
"source": {
"type": "url",
"url": demo_url,
},
}],
"metadata": {
"python-versions": "*",
"platform": "*",
Expand Down
48 changes: 24 additions & 24 deletions tests/installation/test_chooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,12 @@ def test_chooser_chooses_distributions_that_match_the_package_hashes(
chooser = Chooser(pool, env)

package = Package("isort", "4.3.4")
files = [
{
"hash": "sha256:b9c40e9750f3d77e6e4d441d8b0266cf555e7cdabdcff33c4fd06366ca761ef8",
"filename": "isort-4.3.4.tar.gz",
}
]
files = [{
"hash": (
"sha256:b9c40e9750f3d77e6e4d441d8b0266cf555e7cdabdcff33c4fd06366ca761ef8"
),
"filename": "isort-4.3.4.tar.gz",
}]
if source_type == "legacy":
package = Package(
package.name,
Expand Down Expand Up @@ -308,12 +308,12 @@ def test_chooser_chooses_yanked_if_no_others(
chooser = Chooser(pool, env)

package = Package("black", "21.11b0")
files = [
{
"filename": "black-21.11b0-py3-none-any.whl",
"hash": "sha256:0b1f66cbfadcd332ceeaeecf6373d9991d451868d2e2219ad0ac1213fb701117",
}
]
files = [{
"filename": "black-21.11b0-py3-none-any.whl",
"hash": (
"sha256:0b1f66cbfadcd332ceeaeecf6373d9991d451868d2e2219ad0ac1213fb701117"
),
}]
if source_type == "legacy":
package = Package(
package.name,
Expand Down Expand Up @@ -385,12 +385,12 @@ def test_chooser_throws_an_error_if_package_hashes_do_not_match(
chooser = Chooser(pool, env)

package = Package("isort", "4.3.4")
files = [
{
"hash": "sha256:0000000000000000000000000000000000000000000000000000000000000000",
"filename": "isort-4.3.4.tar.gz",
}
]
files = [{
"hash": (
"sha256:0000000000000000000000000000000000000000000000000000000000000000"
),
"filename": "isort-4.3.4.tar.gz",
}]
if source_type == "legacy":
package = Package(
package.name,
Expand Down Expand Up @@ -419,11 +419,11 @@ def test_chooser_md5_remote_fallback_to_sha256_inline_calculation(
source_reference="foo",
source_url="https://foo.bar/simple/",
)
package.files = [
{
"hash": "sha256:9fa123ad707a5c6c944743bf3e11a0e80d86cb518d3cf25320866ca3ef43e2ad",
"filename": "demo-0.1.0.tar.gz",
}
]
package.files = [{
"hash": (
"sha256:9fa123ad707a5c6c944743bf3e11a0e80d86cb518d3cf25320866ca3ef43e2ad"
),
"filename": "demo-0.1.0.tar.gz",
}]
res = chooser.choose_for(package)
assert res.filename == "demo-0.1.0.tar.gz"
Loading

0 comments on commit 58221a9

Please sign in to comment.