diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9958d0348fc..9843fef1cb5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ repos: - id: check-docstring-first - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black exclude: tests/([^/]*/)*fixtures/ diff --git a/src/poetry/console/commands/about.py b/src/poetry/console/commands/about.py index 9b117ae210d..cf2548d6f59 100644 --- a/src/poetry/console/commands/about.py +++ b/src/poetry/console/commands/about.py @@ -21,7 +21,8 @@ def handle(self) -> int: # that. version: Callable[[str], str] = metadata.version - self.line(f"""\ + self.line( + f"""\ Poetry - Package Management for Python Version: {version('poetry')} @@ -30,6 +31,7 @@ def handle(self) -> int: Poetry is a dependency manager tracking local dependencies of your projects\ and libraries. See https://github.com/python-poetry/poetry for more information.\ -""") +""" + ) return 0 diff --git a/tests/console/commands/self/test_add_plugins.py b/tests/console/commands/self/test_add_plugins.py index 78627afa066..427448bfe82 100644 --- a/tests/console/commands/self/test_add_plugins.py +++ b/tests/console/commands/self/test_add_plugins.py @@ -195,7 +195,8 @@ 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" @@ -207,7 +208,8 @@ def test_add_existing_plugin_warns_about_no_operation( [tool.poetry.group.{SelfCommand.ADDITIONAL_PACKAGE_GROUP}.dependencies] poetry-plugin = "^1.2.3" -""") +""" + ) installed.add_package(Package("poetry-plugin", "1.2.3")) @@ -235,7 +237,8 @@ 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" @@ -247,7 +250,8 @@ def test_add_existing_plugin_updates_if_requested( [tool.poetry.group.{SelfCommand.ADDITIONAL_PACKAGE_GROUP}.dependencies] poetry-plugin = "^1.2.3" -""") +""" + ) installed.add_package(Package("poetry-plugin", "1.2.3")) diff --git a/tests/console/commands/test_config.py b/tests/console/commands/test_config.py index 6c15e6a35fb..ee54963ac1d 100644 --- a/tests/console/commands/test_config.py +++ b/tests/console/commands/test_config.py @@ -264,8 +264,7 @@ def test_set_malformed_repositories_setting( tester.execute("repositories.foo bar baz") assert ( - str(e.value) - == "You must pass the url. Example: poetry config repositories.foo" + str(e.value) == "You must pass the url. Example: poetry config repositories.foo" " https://bar.com" ) diff --git a/tests/console/commands/test_init.py b/tests/console/commands/test_init.py index f18570a4eed..881a9b1b020 100644 --- a/tests/console/commands/test_init.py +++ b/tests/console/commands/test_init.py @@ -901,7 +901,9 @@ 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) diff --git a/tests/console/commands/test_install.py b/tests/console/commands/test_install.py index ad42d093465..633a8113a16 100644 --- a/tests/console/commands/test_install.py +++ b/tests/console/commands/test_install.py @@ -348,8 +348,7 @@ def test_remove_untracked_outputs_deprecation_warning( assert tester.status_code == 0 assert ( "The `--remove-untracked` option is deprecated, use the `--sync` option" - " instead.\n" - in tester.io.fetch_error() + " instead.\n" in tester.io.fetch_error() ) diff --git a/tests/console/commands/test_remove.py b/tests/console/commands/test_remove.py index 5fbff275172..6991045f82b 100644 --- a/tests/console/commands/test_remove.py +++ b/tests/console/commands/test_remove.py @@ -65,12 +65,14 @@ def test_remove_without_specific_group_removes_from_all_groups( pyproject: dict[str, Any] = app.poetry.file.read() - groups_content: dict[str, Any] = tomlkit.parse("""\ + groups_content: dict[str, Any] = tomlkit.parse( + """\ [tool.poetry.group.bar.dependencies] foo = "^2.0.0" baz = "^1.0.0" -""") +""" + ) pyproject["tool"]["poetry"]["dependencies"]["foo"] = "^2.0.0" pyproject["tool"]["poetry"]["group"] = groups_content["tool"]["poetry"]["group"] pyproject = cast("TOMLDocument", pyproject) @@ -123,12 +125,14 @@ def test_remove_without_specific_group_removes_from_specific_groups( pyproject: dict[str, Any] = app.poetry.file.read() - groups_content: dict[str, Any] = tomlkit.parse("""\ + groups_content: dict[str, Any] = tomlkit.parse( + """\ [tool.poetry.group.bar.dependencies] foo = "^2.0.0" baz = "^1.0.0" -""") +""" + ) pyproject["tool"]["poetry"]["dependencies"]["foo"] = "^2.0.0" pyproject["tool"]["poetry"]["group"] = groups_content["tool"]["poetry"]["group"] pyproject = cast("TOMLDocument", pyproject) @@ -180,12 +184,14 @@ def test_remove_does_not_live_empty_groups( content: dict[str, Any] = app.poetry.file.read() - groups_content: dict[str, Any] = tomlkit.parse("""\ + groups_content: dict[str, Any] = 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"] content = cast("TOMLDocument", content) @@ -226,12 +232,14 @@ def test_remove_canonicalized_named_removes_dependency_correctly( pyproject: dict[str, Any] = app.poetry.file.read() - groups_content: dict[str, Any] = tomlkit.parse("""\ + groups_content: dict[str, Any] = tomlkit.parse( + """\ [tool.poetry.group.bar.dependencies] foo-bar = "^2.0.0" baz = "^1.0.0" -""") +""" + ) pyproject["tool"]["poetry"]["dependencies"]["foo-bar"] = "^2.0.0" pyproject["tool"]["poetry"].value._insert_after( "dependencies", "group", groups_content["tool"]["poetry"]["group"] diff --git a/tests/inspection/test_info.py b/tests/inspection/test_info.py index 933d48a7f0e..1e84c37417a 100644 --- a/tests/inspection/test_info.py +++ b/tests/inspection/test_info.py @@ -109,20 +109,24 @@ def demo_setup_complex_calls_script( shutil.copytree(fixture_dir("scripts"), scripts_dir) pyproject = source_dir / "pyproject.toml" - pyproject.write_text(f"""\ + pyproject.write_text( + f"""\ [build-system] requires = ["setuptools", "scripts @ {scripts_dir.as_uri()}"] build-backend = "setuptools.build_meta:__legacy__" -""") +""" + ) setup_py = source_dir / "setup.py" - setup_py.write_text("""\ + setup_py.write_text( + """\ import subprocess from setuptools import setup if subprocess.call(["exit-code"]) != 42: raise RuntimeError("Wrong exit code.") setup(name="demo", version="0.1.0", install_requires=[i for i in ["package"]]) -""") +""" + ) return source_dir diff --git a/tests/packages/test_locker.py b/tests/packages/test_locker.py index adf143d5cc5..9699fbd027b 100644 --- a/tests/packages/test_locker.py +++ b/tests/packages/test_locker.py @@ -649,8 +649,7 @@ def test_reading_lock_file_should_raise_an_error_on_missing_metadata( assert ( "The lock file does not have a metadata entry.\nRegenerate the lock file with" - " the `poetry lock` command." - in str(e.value) + " the `poetry lock` command." in str(e.value) ) diff --git a/tests/puzzle/test_solver.py b/tests/puzzle/test_solver.py index 480dd0c1dea..65f013ee3eb 100644 --- a/tests/puzzle/test_solver.py +++ b/tests/puzzle/test_solver.py @@ -4393,8 +4393,7 @@ def test_solver_yanked_warning( assert "The locked version 2 for bar is a yanked version." in error assert ( "The locked version 3 for baz is a yanked version. Reason for being yanked:" - " just wrong" - in error + " just wrong" in error ) assert error.count("is a yanked version") == 2 assert error.count("Reason for being yanked") == 1 diff --git a/tests/utils/env/test_env.py b/tests/utils/env/test_env.py index 535a979e1bf..af571069e0f 100644 --- a/tests/utils/env/test_env.py +++ b/tests/utils/env/test_env.py @@ -178,11 +178,13 @@ 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) diff --git a/tests/utils/test_setup_reader.py b/tests/utils/test_setup_reader.py index cd75aa3eaa8..444debfbf16 100644 --- a/tests/utils/test_setup_reader.py +++ b/tests/utils/test_setup_reader.py @@ -41,7 +41,7 @@ def test_setup_reader_read_minimal_setup_py(setup: Callable[[str], Path]) -> Non def test_setup_reader_read_first_level_setup_call_with_direct_types( - setup: Callable[[str], Path] + setup: Callable[[str], Path], ) -> None: result = SetupReader.read_from_directory(setup("flask")) @@ -77,7 +77,7 @@ def test_setup_reader_read_first_level_setup_call_with_direct_types( def test_setup_reader_read_first_level_setup_call_with_variables( - setup: Callable[[str], Path] + setup: Callable[[str], Path], ) -> None: result = SetupReader.read_from_directory(setup("requests")) @@ -106,7 +106,7 @@ def test_setup_reader_read_first_level_setup_call_with_variables( def test_setup_reader_read_sub_level_setup_call_with_direct_types( - setup: Callable[[str], Path] + setup: Callable[[str], Path], ) -> None: result = SetupReader.read_from_directory(setup("sqlalchemy")) @@ -214,7 +214,7 @@ def test_setup_reader_read_setup_call_in_main(setup: Callable[[str], Path]) -> N def test_setup_reader_read_extras_require_with_variables( - setup: Callable[[str], Path] + setup: Callable[[str], Path], ) -> None: result = SetupReader.read_from_directory(setup("extras_require_with_vars"))