Fix lint issues from previous changes

- Use Path.open() instead of open() in pdf_png.py (PTH123)
- Chain KeyError with 'from e' in pdf_png.py (B904)
- Fix comment placement in section.py to avoid false unused-ignore
- Update watcher test to mock observer.join() instead of time.sleep()
This commit is contained in:
Sina Atalay
2026-03-24 18:57:57 +03:00
parent 515e423817
commit ec884975d4
3 changed files with 8 additions and 9 deletions

View File

@@ -126,13 +126,13 @@ def read_version_from_typst_toml(typst_toml_path: pathlib.Path) -> str:
Returns:
The version string.
"""
with open(typst_toml_path, "rb") as f:
with typst_toml_path.open("rb") as f:
data = tomllib.load(f)
try:
return data["package"]["version"]
except KeyError:
except KeyError as e:
message = f"Could not find version in {typst_toml_path}"
raise RenderCVInternalError(message)
raise RenderCVInternalError(message) from e
def install_bundled_typst_package(

View File

@@ -38,8 +38,8 @@ available_entry_models: tuple[type[EntryModel], ...] = get_args(EntryModel.__val
available_entry_type_names: tuple[str, ...] = tuple(
[entry_type.__name__ for entry_type in available_entry_models] + ["TextEntry"]
)
# ty:ignore is unavoidable here: reduce() constructs a union type at runtime
# that type checkers cannot verify statically:
# reduce() constructs a union type at runtime that type checkers cannot verify
# statically, so the ty:ignore below is unavoidable:
type ListOfEntries = list[str] | reduce( # ty: ignore[invalid-type-form]
or_, [list[entry_type] for entry_type in available_entry_models]
)

View File

@@ -15,10 +15,9 @@ class TestRunFunctionIfFilesChange:
file_path.touch()
mock_function = MagicMock()
with (
patch.object(watcher.watchdog.observers, "Observer"),
patch.object(watcher.time, "sleep", side_effect=KeyboardInterrupt),
):
mock_observer_class = MagicMock()
mock_observer_class.return_value.join.side_effect = KeyboardInterrupt
with patch.object(watcher.watchdog.observers, "Observer", mock_observer_class):
watcher.run_function_if_files_change([file_path], mock_function)
mock_function.assert_called_once()