Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#8993)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Arun Babu Neelicattu <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and abn authored Feb 24, 2024
1 parent 120e737 commit 37028af
Show file tree
Hide file tree
Showing 24 changed files with 2,135 additions and 1,899 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ repos:
- id: check-docstring-first

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.1.1
rev: 24.2.0
hooks:
- id: black
exclude: tests/([^/]*/)*fixtures/

- repo: https://github.com/pre-commit/pre-commit
rev: v3.6.1
rev: v3.6.2
hooks:
- id: validate_manifest

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.2.2
hooks:
- id: ruff
12 changes: 7 additions & 5 deletions src/poetry/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ def normalize(cls, policy: str) -> list[str]:
else:
return [":none:"]

return list({
name.strip() if cls.is_reserved(name) else canonicalize_name(name)
for name in policy.strip().split(",")
if name
})
return list(
{
name.strip() if cls.is_reserved(name) else canonicalize_name(name)
for name in policy.strip().split(",")
if name
}
)

@classmethod
def validator(cls, policy: str) -> bool:
Expand Down
10 changes: 6 additions & 4 deletions src/poetry/console/commands/debug/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ def handle(self) -> int:
self.line("")
self.line("<b>Poetry</b>")
self.line(
"\n".join([
f"<info>Version</info>: <comment>{self.poetry.VERSION}</>",
f"<info>Python</info>: <comment>{poetry_python_version}</>",
])
"\n".join(
[
f"<info>Version</info>: <comment>{self.poetry.VERSION}</>",
f"<info>Python</info>: <comment>{poetry_python_version}</>",
]
)
)
command = self.get_application().get("env info")

Expand Down
16 changes: 9 additions & 7 deletions src/poetry/console/commands/env/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ def _display_complete_info(self, env: Env) -> None:
python = ".".join(str(v) for v in base_env.version_info[:3])
self.line("<b>Base</b>")
self.line(
"\n".join([
f"<info>Platform</info>: <comment>{env.platform}</>",
f"<info>OS</info>: <comment>{env.os}</>",
f"<info>Python</info>: <comment>{python}</>",
f"<info>Path</info>: <comment>{base_env.path}</>",
f"<info>Executable</info>: <comment>{base_env.python}</>",
])
"\n".join(
[
f"<info>Platform</info>: <comment>{env.platform}</>",
f"<info>OS</info>: <comment>{env.os}</>",
f"<info>Python</info>: <comment>{python}</>",
f"<info>Path</info>: <comment>{base_env.path}</>",
f"<info>Executable</info>: <comment>{base_env.python}</>",
]
)
)
12 changes: 7 additions & 5 deletions src/poetry/installation/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ 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
10 changes: 6 additions & 4 deletions src/poetry/masonry/builders/editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,12 @@ def _add_dist_info(self, added_files: list[Path]) -> None:
# write PEP 610 metadata
direct_url_json = dist_info.joinpath("direct_url.json")
direct_url_json.write_text(
json.dumps({
"dir_info": {"editable": True},
"url": self._poetry.file.path.parent.absolute().as_uri(),
})
json.dumps(
{
"dir_info": {"editable": True},
"url": self._poetry.file.path.parent.absolute().as_uri(),
}
)
)
added_files.append(direct_url_json)

Expand Down
12 changes: 7 additions & 5 deletions src/poetry/publishing/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,13 @@ def _upload_file(
raise UploadError(f"Archive ({file}) does not exist")

data = self.post_data(file)
data.update({
# action
":action": "file_upload",
"protocol_version": "1",
})
data.update(
{
# action
":action": "file_upload",
"protocol_version": "1",
}
)

data_to_send: list[tuple[str, Any]] = self._prepare_data(data)

Expand Down
20 changes: 12 additions & 8 deletions src/poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,12 @@ 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 Expand Up @@ -783,10 +785,12 @@ def debug(self, message: str, depth: int = 0) -> None:
if self.is_debugging():
debug_info = str(message)
debug_info = (
"\n".join([
f"<debug>{str(depth).rjust(4)}:</debug> {s}"
for s in debug_info.split("\n")
])
"\n".join(
[
f"<debug>{str(depth).rjust(4)}:</debug> {s}"
for s in debug_info.split("\n")
]
)
+ "\n"
)

Expand Down
10 changes: 6 additions & 4 deletions src/poetry/repositories/pypi_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ def _get_release_info(
files = info.get("files", [])
for file_info in version_info:
if file_info["packagetype"] in SUPPORTED_PACKAGE_TYPES:
files.append({
"file": file_info["filename"],
"hash": "sha256:" + file_info["digests"]["sha256"],
})
files.append(
{
"file": file_info["filename"],
"hash": "sha256:" + file_info["digests"]["sha256"],
}
)
data.files = files

if self._fallback and data.requires_dist is None:
Expand Down
54 changes: 31 additions & 23 deletions tests/console/commands/self/test_show_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ def plugin_distro(plugin_package: Package, tmp_path: Path) -> metadata.Distribut
class MockDistribution(metadata.Distribution):
def read_text(self, filename: str) -> str | None:
if filename == "METADATA":
return "\n".join([
f"Name: {plugin_package.name}",
f"Version: {plugin_package.version}",
*[
f"Requires-Dist: {dep.to_pep_508()}"
for dep in plugin_package.requires
],
])
return "\n".join(
[
f"Name: {plugin_package.name}",
f"Version: {plugin_package.version}",
*[
f"Requires-Dist: {dep.to_pep_508()}"
for dep in plugin_package.requires
],
]
)
return None

def locate_file(self, path: str | PathLike[str]) -> Path:
Expand Down Expand Up @@ -147,10 +149,12 @@ 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 @@ -168,13 +172,15 @@ 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 @@ -195,10 +201,12 @@ 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
24 changes: 13 additions & 11 deletions tests/console/commands/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,19 @@ def tester(patches: None) -> CommandTester:

@pytest.fixture
def init_basic_inputs() -> str:
return "\n".join([
"my-package", # Package name
"1.2.3", # Version
"This is a description", # Description
"n", # Author
"MIT", # License
"~2.7 || ^3.6", # Python
"n", # Interactive packages
"n", # Interactive dev packages
"\n", # Generate
])
return "\n".join(
[
"my-package", # Package name
"1.2.3", # Version
"This is a description", # Description
"n", # Author
"MIT", # License
"~2.7 || ^3.6", # Python
"n", # Interactive packages
"n", # Interactive dev packages
"\n", # Generate
]
)


@pytest.fixture()
Expand Down
Loading

0 comments on commit 37028af

Please sign in to comment.