Skip to content

Commit 82b5e1c

Browse files
authored
Merge pull request #428 from opsmill/stable
Merge stable into develop
2 parents dd16f8d + 8a7b833 commit 82b5e1c

File tree

6 files changed

+20
-14
lines changed

6 files changed

+20
-14
lines changed

changelog/+26b92d23.housekeeping.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Loosen pinned requirement for `whenever` to allow versions from 0.7.2 up to but not including 0.8.0.

infrahub_sdk/ctl/repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def get_repository_config(repo_config_file: Path) -> InfrahubRepositoryConfig:
4545

4646

4747
def load_repository_config_file(repo_config_file: Path) -> dict:
48-
yaml_data = read_file(file_name=repo_config_file)
48+
yaml_data = read_file(file_path=repo_config_file)
4949

5050
try:
5151
data = yaml.safe_load(yaml_data)

infrahub_sdk/utils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,16 @@ def write_to_file(path: Path, value: Any) -> bool:
351351
return written is not None
352352

353353

354-
def read_file(file_name: Path) -> str:
355-
if not file_name.is_file():
356-
raise FileNotValidError(name=str(file_name), message=f"{file_name} is not a valid file")
354+
def read_file(file_path: Path) -> str:
355+
if not file_path.is_file():
356+
raise FileNotValidError(name=str(file_path.name), message=f"{file_path.name}: not found at {file_path.parent}")
357357
try:
358-
with Path.open(file_name, encoding="utf-8") as fobj:
358+
with Path.open(file_path, encoding="utf-8") as fobj:
359359
return fobj.read()
360360
except UnicodeDecodeError as exc:
361-
raise FileNotValidError(name=str(file_name), message=f"Unable to read {file_name} with utf-8 encoding") from exc
361+
raise FileNotValidError(
362+
name=str(file_path.name), message=f"Unable to read {file_path.name} with utf-8 encoding"
363+
) from exc
362364

363365

364366
def get_user_permissions(data: list[dict]) -> dict:

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pytest = { version = "*", optional = true }
4242
pyyaml = { version = "^6", optional = true }
4343
eval-type-backport = { version = "^0.2.2", python = "~3.9" }
4444
dulwich = "^0.21.4"
45-
whenever = "0.7.2"
45+
whenever = ">=0.7.2,<0.8.0"
4646
netutils = "^1.0.0"
4747
click = { version = "8.1.*", optional = true }
4848

tests/unit/sdk/test_yaml.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,22 @@
66

77

88
def test_read_missing_file() -> None:
9-
file = here / "test_data/i_do_not_exist.yml"
10-
yaml_file = YamlFile(location=file)
9+
file_name = "i_do_not_exist.yml"
10+
dir = here / "test_data"
11+
full_path = dir / file_name
12+
yaml_file = YamlFile(location=full_path)
1113
yaml_file.load_content()
1214
assert not yaml_file.valid
13-
assert yaml_file.error_message == f"{file} is not a valid file"
15+
assert yaml_file.error_message == f"{file_name}: not found at {dir}"
1416

1517

1618
def test_read_incorrect_encoding() -> None:
17-
file = here / "test_data/schema_encoding_error.yml"
18-
yaml_file = YamlFile(location=file)
19+
file_name = "schema_encoding_error.yml"
20+
full_path = here / "test_data" / file_name
21+
yaml_file = YamlFile(location=full_path)
1922
yaml_file.load_content()
2023
assert not yaml_file.valid
21-
assert yaml_file.error_message == f"Unable to read {file} with utf-8 encoding"
24+
assert yaml_file.error_message == f"Unable to read {file_name} with utf-8 encoding"
2225

2326

2427
def test_read_multiple_files() -> None:

0 commit comments

Comments
 (0)