Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 1, 2024
1 parent 32d1a06 commit 3ed2300
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
6 changes: 2 additions & 4 deletions scripts/boilercine_tools/add_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ def add_change(typ: ChangeType = "change"):
change = get_change(owner, repo, issue)
content = quote(f"{change.name}\n")
run(
split( # noqa: S603
f"""towncrier create --content {content} {change.id}.{typ}.md"""
),
split(f"""towncrier create --content {content} {change.id}.{typ}.md"""),

Check failure on line 23 in scripts/boilercine_tools/add_changes.py

View workflow job for this annotation

GitHub Actions / ruff (ubuntu-22.04, 3.11)

Ruff (S603)

scripts/boilercine_tools/add_changes.py:23:9: S603 `subprocess` call: check for execution of untrusted input
check=True,
)

Expand Down Expand Up @@ -96,7 +94,7 @@ def query_gh_issue(
) -> dict[str, Any]:
"""Query GitHub for an issue."""
result = run(
[ # noqa: S603, S607
[ # noqa: S607
"gh",
"api",
"graphql",
Expand Down
8 changes: 4 additions & 4 deletions src/boilercine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@


def get_cine_images(
cine_file: Path,
num_frames: int | None = None,
start_frame: int = 0,
cine_file: Path, num_frames: int | None = None, start_frame: int = 0
) -> Iterator[Img]:
"""Get images from a CINE video file."""
images, setup, bpp = read_frames(cine_file, start_frame=start_frame, count=num_frames) # type: ignore
images, setup, bpp = read_frames(
cine_file, start_frame=start_frame, count=num_frames
) # type: ignore
if setup.SoftwareVersion < MIN_VER:
raise RuntimeError(
f"CINE file produced by software older than {MIN_VER}. Reproduce the video"
Expand Down
13 changes: 4 additions & 9 deletions src/boilercine/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,7 @@

def struct_to_dict(structure):
"""Convert a C-style structure to a dictionary from its `_fields_`."""
return {
field[0]: getattr(structure, field[0])
for field in structure._fields_ # noqa: SLF001
}
return {field[0]: getattr(structure, field[0]) for field in structure._fields_}


def capfirst(string: str) -> str:
Expand Down Expand Up @@ -448,7 +445,6 @@ class Setup:

def __post_init__(self):
"""Convert low-level structures to dataclasses."""

self.WBGain = [WBGain2(**struct_to_dict(i)) for i in self.WBGain]
self.WBView = WBGain2(**struct_to_dict(self.WBView))
self.UF = ImFilter(**struct_to_dict(self.UF)) # type: ignore
Expand Down Expand Up @@ -738,11 +734,10 @@ def from_header(cls, header: Header, timezone: tzinfo) -> Self:
cinefileheader = asdict(header.cinefileheader)
for field, value in cinefileheader.items():
if field == "TriggerTime":
trigger_time = cinefileheader[field]
trigger_time = value
flat[capfirst(field)] = (
datetime.fromtimestamp(
trigger_time["seconds"],
timezone,
trigger_time["seconds"], timezone
).astimezone(UTC)
+ timedelta(seconds=trigger_time["fractions"] / 2**32)
).isoformat()
Expand All @@ -759,7 +754,7 @@ def from_header(cls, header: Header, timezone: tzinfo) -> Self:
if field in {"AutoExpRect", "WBView", "CropRect", "TrigTC", "UF"}:
flat |= {
f"{field}{capfirst(subfield)}": subvalue
for subfield, subvalue in setup[field].items()
for subfield, subvalue in value.items()
}
elif field == "WBGain":
flat |= {
Expand Down

0 comments on commit 3ed2300

Please sign in to comment.