Skip to content

Commit

Permalink
chore(ruff-pathlib): manually fix code flagged by "PTH"
Browse files Browse the repository at this point in the history
  • Loading branch information
sujuka99 committed Sep 26, 2023
1 parent 4e2dd33 commit 2d8129e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion kpops/cli/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import importlib
import inspect
import os
from pathlib import Path
import sys
from collections.abc import Iterator
from dataclasses import dataclass, field
Expand All @@ -17,7 +18,7 @@
T = TypeVar("T")
ClassDict = dict[str, type[T]] # type -> class

sys.path.append(os.getcwd())
sys.path.append(str(Path.cwd()))


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion kpops/utils/yaml_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def generate_hashkey(
def load_yaml_file(
file_path: Path, *, substitution: Mapping[str, Any] | None = None,
) -> dict | list[dict]:
with open(file_path) as yaml_file:
with file_path.open() as yaml_file:
return yaml.load(substitute(yaml_file.read(), substitution), Loader=yaml.Loader)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,9 @@ def test_should_create_correct_validate_connector_config_and_name_gets_added(
)

def test_should_parse_validate_connector_config(self, httpx_mock: HTTPXMock):
with open(
with Path(
DEFAULTS_PATH / "connect_validation_response.json",
) as f:
).open() as f:
actual_response = json.load(f)
httpx_mock.add_response(
method="PUT",
Expand Down
4 changes: 2 additions & 2 deletions tests/component_handlers/topic/test_proxy_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def _setup(self, httpx_mock: HTTPXMock):
)
self.proxy_wrapper = ProxyWrapper(pipeline_config=config)

with open(
with Path(
DEFAULTS_PATH / "kafka_rest_proxy_responses" / "cluster-info.json",
) as f:
).open() as f:
cluster_response = json.load(f)

httpx_mock.add_response(
Expand Down
20 changes: 10 additions & 10 deletions tests/component_handlers/topic/test_topic_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ def log_error_mock(self, mocker: MockerFixture) -> MagicMock:

@pytest.fixture(autouse=True)
def get_topic_response_mock(self) -> MagicMock:
with open(
with Path(
DEFAULTS_PATH / "kafka_rest_proxy_responses/get_topic_response.json",
) as f:
).open() as f:
response = json.load(f)

with open(
with Path(
DEFAULTS_PATH / "kafka_rest_proxy_responses/broker_response.json",
) as f:
).open() as f:
broker_response = json.load(f)

with open(
with Path(
DEFAULTS_PATH / "kafka_rest_proxy_responses/topic_config_response.json",
) as f:
).open() as f:
response_topic_config = json.load(f)

wrapper = MagicMock()
Expand All @@ -76,14 +76,14 @@ def get_topic_response_mock(self) -> MagicMock:

@pytest.fixture(autouse=True)
def get_default_topic_response_mock(self) -> MagicMock:
with open(
with Path(
DEFAULTS_PATH / "kafka_rest_proxy_responses/get_default_topic_response.json",
) as f:
).open() as f:
response = json.load(f)

with open(
with Path(
DEFAULTS_PATH / "kafka_rest_proxy_responses/broker_response.json",
) as f:
).open() as f:
broker_response = json.load(f)

wrapper = MagicMock()
Expand Down

0 comments on commit 2d8129e

Please sign in to comment.