From 6d42170203d6006c54e94db6c62b0b19b88357e3 Mon Sep 17 00:00:00 2001 From: Salomon Popp Date: Thu, 28 Mar 2024 09:33:56 +0100 Subject: [PATCH] Update Ruff (#475) --- hooks/__init__.py | 1 + hooks/gen_docs/gen_docs_components.py | 6 +-- hooks/gen_docs/gen_docs_env_vars.py | 1 + hooks/gen_schema.py | 1 + kpops/cli/main.py | 3 +- .../component_handlers/helm_wrapper/model.py | 3 +- .../schema_handler/schema_provider.py | 3 +- kpops/components/base_components/helm_app.py | 6 +-- kpops/utils/gen_schema.py | 3 +- poetry.lock | 54 ++++++++++--------- pyproject.toml | 19 ++++--- tests/cli/test_init.py | 6 ++- tests/cli/test_registry.py | 6 +-- tests/cli/test_schema_generation.py | 15 ++---- .../kafka_connect/test_connect_wrapper.py | 8 +-- .../topic/test_proxy_wrapper.py | 8 +-- .../topic/test_topic_handler.py | 32 +++++------ tests/pipeline/test_components/components.py | 6 +-- .../components.py | 8 +-- tests/pipeline/test_generate.py | 30 ++++++----- 20 files changed, 109 insertions(+), 110 deletions(-) diff --git a/hooks/__init__.py b/hooks/__init__.py index 053c13419..6d0d1797f 100644 --- a/hooks/__init__.py +++ b/hooks/__init__.py @@ -1,4 +1,5 @@ """KPOps pre-commit hooks.""" + from pathlib import Path ROOT = Path(__file__).parents[1].resolve() diff --git a/hooks/gen_docs/gen_docs_components.py b/hooks/gen_docs/gen_docs_components.py index 58edfcf34..2e0a4f1a0 100644 --- a/hooks/gen_docs/gen_docs_components.py +++ b/hooks/gen_docs/gen_docs_components.py @@ -225,9 +225,9 @@ def get_sections(component_name: str, *, exist_changes: bool) -> KpopsComponent: component_sections: list[str] = PIPELINE_COMPONENT_DEPENDENCIES[ # type: ignore [reportGeneralTypeIssues] component_file_name ] - component_sections_not_inherited: list[ - str - ] = DEFAULTS_PIPELINE_COMPONENT_DEPENDENCIES[component_file_name] # type: ignore [reportGeneralTypeIssues] + component_sections_not_inherited: list[str] = ( + DEFAULTS_PIPELINE_COMPONENT_DEPENDENCIES[component_file_name] + ) # type: ignore [reportGeneralTypeIssues] return KpopsComponent(component_sections, component_sections_not_inherited) diff --git a/hooks/gen_docs/gen_docs_env_vars.py b/hooks/gen_docs/gen_docs_env_vars.py index 0f1b7a829..510d464b2 100644 --- a/hooks/gen_docs/gen_docs_env_vars.py +++ b/hooks/gen_docs/gen_docs_env_vars.py @@ -1,4 +1,5 @@ """Generates the documentation on KPOps environment variables.""" + from __future__ import annotations import csv diff --git a/hooks/gen_schema.py b/hooks/gen_schema.py index 3e3cdb0e8..8b9f40db2 100644 --- a/hooks/gen_schema.py +++ b/hooks/gen_schema.py @@ -1,4 +1,5 @@ """Generates the stock KPOps editor integration schemas.""" + from contextlib import redirect_stdout from io import StringIO from pathlib import Path diff --git a/kpops/cli/main.py b/kpops/cli/main.py index 6a55e27eb..6bdcd8dc4 100644 --- a/kpops/cli/main.py +++ b/kpops/cli/main.py @@ -508,8 +508,7 @@ def main( callback=version_callback, is_eager=True, ), -): - ... +): ... if __name__ == "__main__": diff --git a/kpops/component_handlers/helm_wrapper/model.py b/kpops/component_handlers/helm_wrapper/model.py index 8aa0a1374..b81328e46 100644 --- a/kpops/component_handlers/helm_wrapper/model.py +++ b/kpops/component_handlers/helm_wrapper/model.py @@ -140,8 +140,7 @@ def to_command(self) -> list[str]: return command -class HelmUpgradeInstallFlags(HelmFlags): - ... +class HelmUpgradeInstallFlags(HelmFlags): ... class HelmTemplateFlags(HelmFlags): diff --git a/kpops/component_handlers/schema_handler/schema_provider.py b/kpops/component_handlers/schema_handler/schema_provider.py index 0c0423a40..147130ba7 100644 --- a/kpops/component_handlers/schema_handler/schema_provider.py +++ b/kpops/component_handlers/schema_handler/schema_provider.py @@ -15,5 +15,4 @@ class SchemaProvider(ABC): @abstractmethod def provide_schema( self, schema_class: str, models: dict[ModelName, ModelVersion] - ) -> Schema: - ... + ) -> Schema: ... diff --git a/kpops/components/base_components/helm_app.py b/kpops/components/base_components/helm_app.py index ce767367f..94fa3e8cd 100644 --- a/kpops/components/base_components/helm_app.py +++ b/kpops/components/base_components/helm_app.py @@ -40,9 +40,9 @@ class HelmAppValues(KubernetesAppValues): :param name_override: Helm chart name override, assigned automatically """ - name_override: Annotated[ - str, pydantic.StringConstraints(max_length=K8S_LABEL_MAX_LEN) - ] | None = Field( + name_override: ( + Annotated[str, pydantic.StringConstraints(max_length=K8S_LABEL_MAX_LEN)] | None + ) = Field( default=None, title="Nameoverride", description=describe_attr("name_override", __doc__), diff --git a/kpops/utils/gen_schema.py b/kpops/utils/gen_schema.py index c2fd4cda0..b07749ec6 100644 --- a/kpops/utils/gen_schema.py +++ b/kpops/utils/gen_schema.py @@ -34,8 +34,7 @@ class SchemaScope(str, Enum): CONFIG = "config" -class MultiComponentGenerateJsonSchema(GenerateJsonSchema): - ... +class MultiComponentGenerateJsonSchema(GenerateJsonSchema): ... log = logging.getLogger("") diff --git a/poetry.lock b/poetry.lock index 7bb5407bb..fbf97254b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -24,23 +24,25 @@ files = [ [[package]] name = "anyio" -version = "3.6.2" +version = "4.3.0" description = "High level compatibility layer for multiple asynchronous event loop implementations" optional = false -python-versions = ">=3.6.2" +python-versions = ">=3.8" files = [ - {file = "anyio-3.6.2-py3-none-any.whl", hash = "sha256:fbbe32bd270d2a2ef3ed1c5d45041250284e31fc0a4df4a5a6071842051a51e3"}, - {file = "anyio-3.6.2.tar.gz", hash = "sha256:25ea0d673ae30af41a0c442f81cf3b38c7e79fdc7b60335a4c14e05eb0947421"}, + {file = "anyio-4.3.0-py3-none-any.whl", hash = "sha256:048e05d0f6caeed70d731f3db756d35dcc1f35747c8c403364a8332c630441b8"}, + {file = "anyio-4.3.0.tar.gz", hash = "sha256:f75253795a87df48568485fd18cdd2a3fa5c4f7c5be8e5e36637733fce06fed6"}, ] [package.dependencies] +exceptiongroup = {version = ">=1.0.2", markers = "python_version < \"3.11\""} idna = ">=2.8" sniffio = ">=1.1" +typing-extensions = {version = ">=4.1", markers = "python_version < \"3.11\""} [package.extras] -doc = ["packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"] -test = ["contextlib2", "coverage[toml] (>=4.5)", "hypothesis (>=4.0)", "mock (>=4)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (<0.15)", "uvloop (>=0.15)"] -trio = ["trio (>=0.16,<0.22)"] +doc = ["Sphinx (>=7)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"] +test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (>=0.17)"] +trio = ["trio (>=0.23)"] [[package]] name = "attrs" @@ -1544,28 +1546,28 @@ jupyter = ["ipywidgets (>=7.5.1,<8.0.0)"] [[package]] name = "ruff" -version = "0.1.7" +version = "0.3.4" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.1.7-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:7f80496854fdc65b6659c271d2c26e90d4d401e6a4a31908e7e334fab4645aac"}, - {file = "ruff-0.1.7-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:1ea109bdb23c2a4413f397ebd8ac32cb498bee234d4191ae1a310af760e5d287"}, - {file = "ruff-0.1.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8b0c2de9dd9daf5e07624c24add25c3a490dbf74b0e9bca4145c632457b3b42a"}, - {file = "ruff-0.1.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:69a4bed13bc1d5dabf3902522b5a2aadfebe28226c6269694283c3b0cecb45fd"}, - {file = "ruff-0.1.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:de02ca331f2143195a712983a57137c5ec0f10acc4aa81f7c1f86519e52b92a1"}, - {file = "ruff-0.1.7-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:45b38c3f8788a65e6a2cab02e0f7adfa88872696839d9882c13b7e2f35d64c5f"}, - {file = "ruff-0.1.7-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6c64cb67b2025b1ac6d58e5ffca8f7b3f7fd921f35e78198411237e4f0db8e73"}, - {file = "ruff-0.1.7-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9dcc6bb2f4df59cb5b4b40ff14be7d57012179d69c6565c1da0d1f013d29951b"}, - {file = "ruff-0.1.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:df2bb4bb6bbe921f6b4f5b6fdd8d8468c940731cb9406f274ae8c5ed7a78c478"}, - {file = "ruff-0.1.7-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:276a89bcb149b3d8c1b11d91aa81898fe698900ed553a08129b38d9d6570e717"}, - {file = "ruff-0.1.7-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:90c958fe950735041f1c80d21b42184f1072cc3975d05e736e8d66fc377119ea"}, - {file = "ruff-0.1.7-py3-none-musllinux_1_2_i686.whl", hash = "sha256:6b05e3b123f93bb4146a761b7a7d57af8cb7384ccb2502d29d736eaade0db519"}, - {file = "ruff-0.1.7-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:290ecab680dce94affebefe0bbca2322a6277e83d4f29234627e0f8f6b4fa9ce"}, - {file = "ruff-0.1.7-py3-none-win32.whl", hash = "sha256:416dfd0bd45d1a2baa3b1b07b1b9758e7d993c256d3e51dc6e03a5e7901c7d80"}, - {file = "ruff-0.1.7-py3-none-win_amd64.whl", hash = "sha256:4af95fd1d3b001fc41325064336db36e3d27d2004cdb6d21fd617d45a172dd96"}, - {file = "ruff-0.1.7-py3-none-win_arm64.whl", hash = "sha256:0683b7bfbb95e6df3c7c04fe9d78f631f8e8ba4868dfc932d43d690698057e2e"}, - {file = "ruff-0.1.7.tar.gz", hash = "sha256:dffd699d07abf54833e5f6cc50b85a6ff043715da8788c4a79bcd4ab4734d306"}, + {file = "ruff-0.3.4-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:60c870a7d46efcbc8385d27ec07fe534ac32f3b251e4fc44b3cbfd9e09609ef4"}, + {file = "ruff-0.3.4-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:6fc14fa742e1d8f24910e1fff0bd5e26d395b0e0e04cc1b15c7c5e5fe5b4af91"}, + {file = "ruff-0.3.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d3ee7880f653cc03749a3bfea720cf2a192e4f884925b0cf7eecce82f0ce5854"}, + {file = "ruff-0.3.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:cf133dd744f2470b347f602452a88e70dadfbe0fcfb5fd46e093d55da65f82f7"}, + {file = "ruff-0.3.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3f3860057590e810c7ffea75669bdc6927bfd91e29b4baa9258fd48b540a4365"}, + {file = "ruff-0.3.4-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:986f2377f7cf12efac1f515fc1a5b753c000ed1e0a6de96747cdf2da20a1b369"}, + {file = "ruff-0.3.4-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c4fd98e85869603e65f554fdc5cddf0712e352fe6e61d29d5a6fe087ec82b76c"}, + {file = "ruff-0.3.4-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:64abeed785dad51801b423fa51840b1764b35d6c461ea8caef9cf9e5e5ab34d9"}, + {file = "ruff-0.3.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:df52972138318bc7546d92348a1ee58449bc3f9eaf0db278906eb511889c4b50"}, + {file = "ruff-0.3.4-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:98e98300056445ba2cc27d0b325fd044dc17fcc38e4e4d2c7711585bd0a958ed"}, + {file = "ruff-0.3.4-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:519cf6a0ebed244dce1dc8aecd3dc99add7a2ee15bb68cf19588bb5bf58e0488"}, + {file = "ruff-0.3.4-py3-none-musllinux_1_2_i686.whl", hash = "sha256:bb0acfb921030d00070539c038cd24bb1df73a2981e9f55942514af8b17be94e"}, + {file = "ruff-0.3.4-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:cf187a7e7098233d0d0c71175375c5162f880126c4c716fa28a8ac418dcf3378"}, + {file = "ruff-0.3.4-py3-none-win32.whl", hash = "sha256:af27ac187c0a331e8ef91d84bf1c3c6a5dea97e912a7560ac0cef25c526a4102"}, + {file = "ruff-0.3.4-py3-none-win_amd64.whl", hash = "sha256:de0d5069b165e5a32b3c6ffbb81c350b1e3d3483347196ffdf86dc0ef9e37dd6"}, + {file = "ruff-0.3.4-py3-none-win_arm64.whl", hash = "sha256:6810563cc08ad0096b57c717bd78aeac888a1bfd38654d9113cb3dc4d3f74232"}, + {file = "ruff-0.3.4.tar.gz", hash = "sha256:f0f4484c6541a99862b693e13a151435a279b271cff20e37101116a21e2a1ad1"}, ] [[package]] @@ -1861,4 +1863,4 @@ watchmedo = ["PyYAML (>=3.10)"] [metadata] lock-version = "2.0" python-versions = ">=3.10, <3.13" -content-hash = "e511a2c2f2824fc86d265eccfe732789d24a8e2023a4bef29b253aa24eb7c9ce" +content-hash = "f21962e604d76ff8a2743774ade55e142a91caa69c2e0f624460f31a8e49bce6" diff --git a/pyproject.toml b/pyproject.toml index 9fdde7e44..fc6e903a8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ kpops = "kpops.cli.main:app" [tool.poetry.dependencies] python = ">=3.10, <3.13" +anyio = "^4.3.0" pydantic = "^2.5.3" pydantic-settings = "^2.0.3" rich = "^12.4.4" @@ -42,7 +43,7 @@ pytest-mock = "^3.10.0" pytest-timeout = "^2.1.0" pytest-snapshot = "^0.9.0" pre-commit = "^2.19.0" -ruff = "^0.1.7" +ruff = "^0.3.4" typer-cli = "^0.0.13" pyright = "^1.1.352" pytest-rerunfailures = "^11.1.2" @@ -73,6 +74,12 @@ reportIncompatibleMethodOverride = false # reportIncompatibleMethodOverride = "warning" [tool.ruff] +output-format = "grouped" +show-fixes = true +target-version = "py310" +extend-exclude = ["tests/*snapshots/*"] + +[tool.ruff.lint] ignore = [ # Rules in conflict with `ruff-format` -- START "W191", # Checks for indentation that uses tabs. Spaces are preferred. @@ -161,19 +168,15 @@ select = [ # "FURB", # refurb, add when out of nursery # "LOG", # flake8-logging, add when out of nursery ] -output-format = "grouped" -show-fixes = true task-tags = ["TODO", "HACK", "FIXME", "XXX"] -target-version = "py310" -extend-exclude = ["tests/*snapshots/*"] -[tool.ruff.extend-per-file-ignores] +[tool.ruff.lint.extend-per-file-ignores] "tests/*/__init__.py" = ["F401"] -[tool.ruff.flake8-bugbear] +[tool.ruff.lint.flake8-bugbear] extend-immutable-calls = ["typer.Argument"] -[tool.ruff.flake8-type-checking] +[tool.ruff.lint.flake8-type-checking] runtime-evaluated-base-classes = ["pydantic.BaseModel"] [build-system] diff --git a/tests/cli/test_init.py b/tests/cli/test_init.py index f3245f814..8d4790d23 100644 --- a/tests/cli/test_init.py +++ b/tests/cli/test_init.py @@ -15,8 +15,10 @@ def test_create_config(tmp_path: Path): req_conf_name = "config_with_only_required" create_config(opt_conf_name, tmp_path, True) create_config(req_conf_name, tmp_path, False) - assert (opt_conf := Path(tmp_path / (opt_conf_name + ".yaml"))).exists() - assert (req_conf := Path(tmp_path / (req_conf_name + ".yaml"))).exists() + opt_conf = (tmp_path / opt_conf_name).with_suffix(".yaml") + assert opt_conf.exists() + req_conf = (tmp_path / req_conf_name).with_suffix(".yaml") + assert req_conf.exists() assert len(opt_conf.read_text()) > len(req_conf.read_text()) diff --git a/tests/cli/test_registry.py b/tests/cli/test_registry.py index 473c340c4..f305c24a3 100644 --- a/tests/cli/test_registry.py +++ b/tests/cli/test_registry.py @@ -8,12 +8,10 @@ from tests.cli.resources.custom_module import CustomSchemaProvider -class SubComponent(PipelineComponent): - ... +class SubComponent(PipelineComponent): ... -class SubSubComponent(SubComponent): - ... +class SubSubComponent(SubComponent): ... class Unrelated: diff --git a/tests/cli/test_schema_generation.py b/tests/cli/test_schema_generation.py index 8ca0a357e..4e1b4aa09 100644 --- a/tests/cli/test_schema_generation.py +++ b/tests/cli/test_schema_generation.py @@ -29,29 +29,24 @@ class EmptyPipelineComponent(PipelineComponent): # abstract component inheriting from ABC should be excluded -class AbstractBaseComponent(PipelineComponent, ABC): - ... +class AbstractBaseComponent(PipelineComponent, ABC): ... # abstract component with abstractmethods should be excluded class AbstractPipelineComponent(AbstractBaseComponent): @abstractmethod - def not_implemented(self) -> None: - ... + def not_implemented(self) -> None: ... -class SubPipelineComponent(EmptyPipelineComponent): - ... +class SubPipelineComponent(EmptyPipelineComponent): ... # type is inherited from SubPipelineComponent -class SubPipelineComponentNoSchemaTypeNoType(SubPipelineComponent): - ... +class SubPipelineComponentNoSchemaTypeNoType(SubPipelineComponent): ... # Correctly defined -class SubPipelineComponentCorrect(SubPipelineComponent): - ... +class SubPipelineComponentCorrect(SubPipelineComponent): ... # Correctly defined, docstr test diff --git a/tests/component_handlers/kafka_connect/test_connect_wrapper.py b/tests/component_handlers/kafka_connect/test_connect_wrapper.py index 7dff70a42..d84d3b91d 100644 --- a/tests/component_handlers/kafka_connect/test_connect_wrapper.py +++ b/tests/component_handlers/kafka_connect/test_connect_wrapper.py @@ -1,10 +1,10 @@ import json import sys -from pathlib import Path from unittest.mock import AsyncMock, MagicMock, patch import pytest import pytest_asyncio +from anyio import Path from pytest_httpx import HTTPXMock from kpops.component_handlers.kafka_connect.connect_wrapper import ConnectWrapper @@ -508,10 +508,10 @@ async def test_should_create_correct_validate_connector_config_and_name_gets_add @pytest.mark.asyncio() async def test_should_parse_validate_connector_config(self, httpx_mock: HTTPXMock): - with Path( + content = await Path( RESOURCES_PATH / "connect_validation_response.json", - ).open() as f: - actual_response = json.load(f) + ).read_text() + actual_response = json.loads(content) httpx_mock.add_response( method="PUT", diff --git a/tests/component_handlers/topic/test_proxy_wrapper.py b/tests/component_handlers/topic/test_proxy_wrapper.py index 4db30b9b6..e59b116a1 100644 --- a/tests/component_handlers/topic/test_proxy_wrapper.py +++ b/tests/component_handlers/topic/test_proxy_wrapper.py @@ -1,10 +1,10 @@ import json -from pathlib import Path from typing import Any from unittest.mock import AsyncMock, MagicMock, patch import pytest import pytest_asyncio +from anyio import Path from pydantic import AnyUrl from pytest_httpx import HTTPXMock from pytest_mock import MockerFixture @@ -35,10 +35,10 @@ def log_debug_mock(self, mocker: MockerFixture) -> MagicMock: async def _setup(self, httpx_mock: HTTPXMock): config = KpopsConfig() self.proxy_wrapper = ProxyWrapper(config.kafka_rest) - with Path( + content = await Path( RESOURCES_PATH / "kafka_rest_proxy_responses" / "cluster-info.json", - ).open() as f: - cluster_response = json.load(f) + ).read_text() + cluster_response = json.loads(content) httpx_mock.add_response( method="GET", diff --git a/tests/component_handlers/topic/test_topic_handler.py b/tests/component_handlers/topic/test_topic_handler.py index 5b092d054..5109652af 100644 --- a/tests/component_handlers/topic/test_topic_handler.py +++ b/tests/component_handlers/topic/test_topic_handler.py @@ -1,11 +1,11 @@ import json import logging -from pathlib import Path from unittest import mock from unittest.mock import AsyncMock, MagicMock import pytest import pytest_asyncio +from anyio import Path from pytest_mock import MockerFixture from kpops.component_handlers.topic.exception import ( @@ -50,20 +50,20 @@ def log_error_mock(self, mocker: MockerFixture) -> MagicMock: @pytest_asyncio.fixture(autouse=True) async def get_topic_response_mock(self) -> MagicMock: - with Path( + content = await Path( RESOURCES_PATH / "kafka_rest_proxy_responses/get_topic_response.json", - ).open() as f: - response = json.load(f) + ).read_text() + response = json.loads(content) - with Path( + content = await Path( RESOURCES_PATH / "kafka_rest_proxy_responses/broker_response.json", - ).open() as f: - broker_response = json.load(f) + ).read_text() + broker_response = json.loads(content) - with Path( + content = await Path( RESOURCES_PATH / "kafka_rest_proxy_responses/topic_config_response.json", - ).open() as f: - response_topic_config = json.load(f) + ).read_text() + response_topic_config = json.loads(content) wrapper = AsyncMock() wrapper.get_topic.return_value = TopicResponse(**response) @@ -75,16 +75,16 @@ async def get_topic_response_mock(self) -> MagicMock: @pytest_asyncio.fixture(autouse=True) async def get_default_topic_response_mock(self) -> MagicMock: - with Path( + content = await Path( RESOURCES_PATH / "kafka_rest_proxy_responses/get_default_topic_response.json", - ).open() as f: - response = json.load(f) + ).read_text() + response = json.loads(content) - with Path( + content = await Path( RESOURCES_PATH / "kafka_rest_proxy_responses/broker_response.json", - ).open() as f: - broker_response = json.load(f) + ).read_text() + broker_response = json.loads(content) wrapper = AsyncMock() wrapper.get_topic.return_value = TopicResponse(**response) diff --git a/tests/pipeline/test_components/components.py b/tests/pipeline/test_components/components.py index bc32d0856..36f24f938 100644 --- a/tests/pipeline/test_components/components.py +++ b/tests/pipeline/test_components/components.py @@ -18,12 +18,10 @@ from kpops.components.base_components.models.topic import OutputTopicTypes, TopicConfig -class ScheduledProducer(ProducerApp): - ... +class ScheduledProducer(ProducerApp): ... -class Converter(StreamsApp): - ... +class Converter(StreamsApp): ... class SubStreamsApp(StreamsApp): diff --git a/tests/pipeline/test_components_without_schema_handler/components.py b/tests/pipeline/test_components_without_schema_handler/components.py index 368304784..1d54a9f7a 100644 --- a/tests/pipeline/test_components_without_schema_handler/components.py +++ b/tests/pipeline/test_components_without_schema_handler/components.py @@ -10,17 +10,13 @@ from kpops.components.base_components.models.topic import OutputTopicTypes -class ScheduledProducer(ProducerApp): - ... +class ScheduledProducer(ProducerApp): ... -class Converter(StreamsApp): - ... +class Converter(StreamsApp): ... class ShouldInflate(StreamsApp): - ... - @override def inflate(self) -> list[PipelineComponent]: inflate_steps = super().inflate() diff --git a/tests/pipeline/test_generate.py b/tests/pipeline/test_generate.py index c40e57d32..8b237f705 100644 --- a/tests/pipeline/test_generate.py +++ b/tests/pipeline/test_generate.py @@ -586,12 +586,15 @@ def test_short_topic_definition(self): assert input_components["component-extra-pattern"]["role"] == "role" def test_kubernetes_app_name_validation(self): - with pytest.raises( - ParsingException, - match="Error enriching filter component illegal_name", - ), pytest.raises( - ValueError, - match="The component name illegal_name is invalid for Kubernetes.", + with ( + pytest.raises( + ParsingException, + match="Error enriching filter component illegal_name", + ), + pytest.raises( + ValueError, + match="The component name illegal_name is invalid for Kubernetes.", + ), ): runner.invoke( app, @@ -606,12 +609,15 @@ def test_kubernetes_app_name_validation(self): ) def test_validate_unique_step_names(self): - with pytest.raises( - ParsingException, - match="Error enriching pipeline-component component component", - ), pytest.raises( - ValidationError, - match="Pipeline steps must have unique id, 'component-resources-pipeline-duplicate-step-names-component' already exists.", + with ( + pytest.raises( + ParsingException, + match="Error enriching pipeline-component component component", + ), + pytest.raises( + ValidationError, + match="Pipeline steps must have unique id, 'component-resources-pipeline-duplicate-step-names-component' already exists.", + ), ): runner.invoke( app,