Skip to content

Merge stable into develop #428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/+26b92d23.housekeeping.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Loosen pinned requirement for `whenever` to allow versions from 0.7.2 up to but not including 0.8.0.
2 changes: 1 addition & 1 deletion infrahub_sdk/ctl/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_repository_config(repo_config_file: Path) -> InfrahubRepositoryConfig:


def load_repository_config_file(repo_config_file: Path) -> dict:
yaml_data = read_file(file_name=repo_config_file)
yaml_data = read_file(file_path=repo_config_file)

try:
data = yaml.safe_load(yaml_data)
Expand Down
12 changes: 7 additions & 5 deletions infrahub_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,16 @@ def write_to_file(path: Path, value: Any) -> bool:
return written is not None


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


def get_user_permissions(data: list[dict]) -> dict:
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pytest = { version = "*", optional = true }
pyyaml = { version = "^6", optional = true }
eval-type-backport = { version = "^0.2.2", python = "~3.9" }
dulwich = "^0.21.4"
whenever = "0.7.2"
whenever = ">=0.7.2,<0.8.0"
netutils = "^1.0.0"
click = { version = "8.1.*", optional = true }

Expand Down
15 changes: 9 additions & 6 deletions tests/unit/sdk/test_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@


def test_read_missing_file() -> None:
file = here / "test_data/i_do_not_exist.yml"
yaml_file = YamlFile(location=file)
file_name = "i_do_not_exist.yml"
dir = here / "test_data"
full_path = dir / file_name
yaml_file = YamlFile(location=full_path)
yaml_file.load_content()
assert not yaml_file.valid
assert yaml_file.error_message == f"{file} is not a valid file"
assert yaml_file.error_message == f"{file_name}: not found at {dir}"


def test_read_incorrect_encoding() -> None:
file = here / "test_data/schema_encoding_error.yml"
yaml_file = YamlFile(location=file)
file_name = "schema_encoding_error.yml"
full_path = here / "test_data" / file_name
yaml_file = YamlFile(location=full_path)
yaml_file.load_content()
assert not yaml_file.valid
assert yaml_file.error_message == f"Unable to read {file} with utf-8 encoding"
assert yaml_file.error_message == f"Unable to read {file_name} with utf-8 encoding"


def test_read_multiple_files() -> None:
Expand Down