Commit 5517f371 by Bartek Sokorski Committed by Bartosz Sokorski

Update pre-commit config and fix issues

parent 66bb5644
......@@ -21,7 +21,7 @@ repos:
- id: check-docstring-first
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
rev: v1.10.0
hooks:
- id: python-check-mock-methods
- id: python-use-type-annotations
......@@ -32,10 +32,10 @@ repos:
hooks:
- id: pyupgrade
args: [--py37-plus]
exclude: ^(install|get)-poetry.py$
exclude: ^install-poetry.py$
- repo: https://github.com/hadialqattan/pycln
rev: v2.1.2
rev: v2.1.3
hooks:
- id: pycln
args: [--all]
......@@ -49,7 +49,7 @@ repos:
args: [--add-import, from __future__ import annotations]
exclude: |
(?x)(
^(install|get)-poetry.py$
^install-poetry.py$
| ^src/poetry/__init__.py$
)
- id: isort
......@@ -58,12 +58,12 @@ repos:
args: [--lines-after-imports, "-1"]
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit
rev: v2.21.0
rev: v3.2.2
hooks:
- id: validate_manifest
......
......@@ -21,8 +21,7 @@ class AboutCommand(Command):
# that.
version: Callable[[str], str] = metadata.version
self.line(
f"""\
self.line(f"""\
<info>Poetry - Package Management for Python
Version: {version('poetry')}
......@@ -31,7 +30,6 @@ Poetry-Core Version: {version('poetry-core')}</info>
<comment>Poetry is a dependency manager tracking local dependencies of your projects\
and libraries.
See <fg=blue>https://github.com/python-poetry/poetry</> for more information.</comment>\
"""
)
""")
return 0
......@@ -257,9 +257,9 @@ lists all packages available."""
latest = locked
latest_packages[locked.pretty_name] = latest
update_status = latest_statuses[
locked.pretty_name
] = self.get_update_status(latest, locked)
update_status = latest_statuses[locked.pretty_name] = (
self.get_update_status(latest, locked)
)
if not self.option("outdated") or update_status != "up-to-date":
name_length = max(name_length, current_length)
......
......@@ -397,9 +397,9 @@ class Authenticator:
self._configured_repositories = {}
for repository_name in self._config.get("repositories", []):
url = self._config.get(f"repositories.{repository_name}.url")
self._configured_repositories[
repository_name
] = AuthenticatorRepositoryConfig(repository_name, url)
self._configured_repositories[repository_name] = (
AuthenticatorRepositoryConfig(repository_name, url)
)
return self._configured_repositories
......
......@@ -96,9 +96,9 @@ def _parse_dependency_specification_path(
return {
"name": package.name,
"path": path.relative_to(cwd).as_posix()
if not is_absolute
else path.as_posix(),
"path": (
path.relative_to(cwd).as_posix() if not is_absolute else path.as_posix()
),
}
return None
......
......@@ -192,8 +192,7 @@ def test_add_existing_plugin_warns_about_no_operation(
) -> None:
pyproject = SelfCommand.get_default_system_pyproject_file()
with open(pyproject, "w", encoding="utf-8", newline="") as f:
f.write(
f"""\
f.write(f"""\
[tool.poetry]
name = "poetry-instance"
version = "1.2.0"
......@@ -205,8 +204,7 @@ python = "^3.6"
[tool.poetry.group.{SelfCommand.ADDITIONAL_PACKAGE_GROUP}.dependencies]
poetry-plugin = "^1.2.3"
"""
)
""")
installed.add_package(Package("poetry-plugin", "1.2.3"))
......@@ -233,8 +231,7 @@ def test_add_existing_plugin_updates_if_requested(
) -> None:
pyproject = SelfCommand.get_default_system_pyproject_file()
with open(pyproject, "w", encoding="utf-8", newline="") as f:
f.write(
f"""\
f.write(f"""\
[tool.poetry]
name = "poetry-instance"
version = "1.2.0"
......@@ -246,8 +243,7 @@ python = "^3.6"
[tool.poetry.group.{SelfCommand.ADDITIONAL_PACKAGE_GROUP}.dependencies]
poetry-plugin = "^1.2.3"
"""
)
""")
installed.add_package(Package("poetry-plugin", "1.2.3"))
......
......@@ -921,9 +921,7 @@ def test_init_existing_pyproject_consistent_linesep(
existing_section = """
[tool.black]
line-length = 88
""".replace(
"\n", linesep
)
""".replace("\n", linesep)
with open(pyproject_file, "w", newline="") as f:
f.write(existing_section)
tester.execute(inputs=init_basic_inputs)
......
......@@ -58,14 +58,12 @@ def test_remove_without_specific_group_removes_from_all_groups(
content = app.poetry.file.read()
groups_content = tomlkit.parse(
"""\
groups_content = tomlkit.parse("""\
[tool.poetry.group.bar.dependencies]
foo = "^2.0.0"
baz = "^1.0.0"
"""
)
""")
content["tool"]["poetry"]["dependencies"]["foo"] = "^2.0.0"
content["tool"]["poetry"]["group"] = groups_content["tool"]["poetry"]["group"]
app.poetry.file.write(content)
......@@ -115,14 +113,12 @@ def test_remove_without_specific_group_removes_from_specific_groups(
content = app.poetry.file.read()
groups_content = tomlkit.parse(
"""\
groups_content = tomlkit.parse("""\
[tool.poetry.group.bar.dependencies]
foo = "^2.0.0"
baz = "^1.0.0"
"""
)
""")
content["tool"]["poetry"]["dependencies"]["foo"] = "^2.0.0"
content["tool"]["poetry"]["group"] = groups_content["tool"]["poetry"]["group"]
app.poetry.file.write(content)
......@@ -172,14 +168,12 @@ def test_remove_does_not_live_empty_groups(
content = app.poetry.file.read()
groups_content = tomlkit.parse(
"""\
groups_content = tomlkit.parse("""\
[tool.poetry.group.bar.dependencies]
foo = "^2.0.0"
baz = "^1.0.0"
"""
)
""")
content["tool"]["poetry"]["dependencies"]["foo"] = "^2.0.0"
content["tool"]["poetry"]["group"] = groups_content["tool"]["poetry"]["group"]
app.poetry.file.write(content)
......@@ -218,14 +212,12 @@ def test_remove_canonicalized_named_removes_dependency_correctly(
content = app.poetry.file.read()
groups_content = tomlkit.parse(
"""\
groups_content = tomlkit.parse("""\
[tool.poetry.group.bar.dependencies]
foo-bar = "^2.0.0"
baz = "^1.0.0"
"""
)
""")
content["tool"]["poetry"]["dependencies"]["foo-bar"] = "^2.0.0"
content["tool"]["poetry"].value._insert_after(
"dependencies", "group", groups_content["tool"]["poetry"]["group"]
......
......@@ -1091,13 +1091,11 @@ def test_call_does_not_block_on_full_pipe(
) -> None:
"""see https://github.com/python-poetry/poetry/issues/7698"""
script = tmp_path / "script.py"
script.write_text(
f"""\
script.write_text(f"""\
import sys
for i in range(10000):
print('just print a lot of text to fill the buffer', file={out})
"""
)
""")
def target(result: list[int]) -> None:
tmp_venv.run("python", str(script), call=True)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment