Commit 5517f371 by Bartek Sokorski Committed by Bartosz Sokorski

Update pre-commit config and fix issues

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