Skip to content

Commit

Permalink
apply UP rule
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemia committed Feb 11, 2025
1 parent 9cde3f9 commit 5335e02
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 29 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ select = [
# "B", # flake8-bugbear
"B006", # flake8-bugbear: Do not use mutable data structures for argument defaults
"C4", # flake8-comprehensions
# "UP", # pyupgrade
"UP", # pyupgrade
]
ignore = [
"E741", # Ambiguous variable name: `I`
Expand Down
2 changes: 1 addition & 1 deletion src/ffmpeg/common/serialize.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import absolute_import, annotations
from __future__ import annotations

import importlib
import json
Expand Down
2 changes: 1 addition & 1 deletion src/ffmpeg/dag/io/output_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def _output_node(

def output(
self,
*streams: "FilterableStream",
*streams: FilterableStream,
filename: str | Path,
f: String = None,
c: String = None,
Expand Down
28 changes: 14 additions & 14 deletions src/ffmpeg/dag/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class FilterNode(Node):
def repr(self) -> str:
return self.name

def video(self, index: int) -> "VideoStream":
def video(self, index: int) -> VideoStream:
"""
Return the video stream at the specified index
Expand All @@ -76,7 +76,7 @@ def video(self, index: int) -> "VideoStream":
)
return VideoStream(node=self, index=video_outputs[index])

def audio(self, index: int) -> "AudioStream":
def audio(self, index: int) -> AudioStream:
"""
Return the audio stream at the specified index
Expand Down Expand Up @@ -171,7 +171,7 @@ class FilterableStream(Stream, OutputArgs):
A stream that can be used as input to a filter
"""

node: "FilterNode | InputNode"
node: FilterNode | InputNode

@override
def _output_node(
Expand All @@ -196,11 +196,11 @@ def _output_node(

def vfilter(
self,
*streams: "FilterableStream",
*streams: FilterableStream,
name: str,
input_typings: tuple[StreamType, ...] = (StreamType.video,),
**kwargs: Any,
) -> "VideoStream":
) -> VideoStream:
"""
Apply a custom video filter which has only one output to this stream
Expand All @@ -223,11 +223,11 @@ def vfilter(

def afilter(
self,
*streams: "FilterableStream",
*streams: FilterableStream,
name: str,
input_typings: tuple[StreamType, ...] = (StreamType.audio,),
**kwargs: Any,
) -> "AudioStream":
) -> AudioStream:
"""
Apply a custom audio filter which has only one output to this stream
Expand All @@ -250,12 +250,12 @@ def afilter(

def filter_multi_output(
self,
*streams: "FilterableStream",
*streams: FilterableStream,
name: str,
input_typings: tuple[StreamType, ...] = (),
output_typings: tuple[StreamType, ...] = (),
**kwargs: Any,
) -> "FilterNode":
) -> FilterNode:
"""
Apply a custom filter which has multiple outputs to this stream
Expand Down Expand Up @@ -339,7 +339,7 @@ def repr(self) -> str:
return os.path.basename(self.filename)

@property
def video(self) -> "VideoStream":
def video(self) -> VideoStream:
"""
Return the video stream of this node
Expand All @@ -351,7 +351,7 @@ def video(self) -> "VideoStream":
return VideoStream(node=self)

@property
def audio(self) -> "AudioStream":
def audio(self) -> AudioStream:
"""
Return the audio stream of this node
Expand All @@ -362,7 +362,7 @@ def audio(self) -> "AudioStream":

return AudioStream(node=self)

def stream(self) -> "AVStream":
def stream(self) -> AVStream:
"""
Return the output stream of this node
Expand Down Expand Up @@ -400,7 +400,7 @@ class OutputNode(Node):
def repr(self) -> str:
return os.path.basename(self.filename)

def stream(self) -> "OutputStream":
def stream(self) -> OutputStream:
"""
Return the output stream of this node
Expand Down Expand Up @@ -466,7 +466,7 @@ class GlobalNode(Node):
def repr(self) -> str:
return " ".join(self.get_args())

def stream(self) -> "GlobalStream":
def stream(self) -> GlobalStream:
"""
Return the output stream of this node
Expand Down
4 changes: 2 additions & 2 deletions src/ffmpeg/dag/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _repr_png_(self) -> bytes: # pragma: no cover
return f.read()

def _repr_svg_(self) -> str: # pragma: no cover
with open(self.view(format="svg"), "r") as f:
with open(self.view(format="svg")) as f:
return f.read()


Expand Down Expand Up @@ -206,5 +206,5 @@ def _repr_png_(self) -> bytes: # pragma: no cover
return f.read()

def _repr_svg_(self) -> str: # pragma: no cover
with open(self.view(format="svg"), "r") as f:
with open(self.view(format="svg")) as f:
return f.read()
4 changes: 1 addition & 3 deletions src/ffmpeg/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,4 @@ def __init__(self, retcode: int | None, cmd: str, stdout: bytes, stderr: bytes):
self.cmd = cmd
self.retcode = retcode

super(FFMpegExecuteError, self).__init__(
f"{cmd} error (see stderr output for detail) {stderr!r}"
)
super().__init__(f"{cmd} error (see stderr output for detail) {stderr!r}")
11 changes: 6 additions & 5 deletions src/ffmpeg/utils/escaping.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Iterable
from collections.abc import Iterable
from typing import Any


def escape(text: str | int | float, chars: str = "\\'=:") -> str:
Expand Down Expand Up @@ -39,11 +40,11 @@ def convert_kwargs_to_cmd_line_args(kwargs: dict[str, Any]) -> list[str]:
v = kwargs[k]
if isinstance(v, Iterable) and not isinstance(v, str):
for value in v:
args.append("-{}".format(k))
args.append(f"-{k}")
if value is not None:
args.append("{}".format(value))
args.append(f"{value}")
continue
args.append("-{}".format(k))
args.append(f"-{k}")
if v is not None:
args.append("{}".format(v))
args.append(f"{v}")
return args
4 changes: 2 additions & 2 deletions src/scripts/manual/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def init_config() -> None:
if filter.is_dynamic_input or filter.is_dynamic_output:
try:
info = load(FFMpegFilterManuallyDefined, filter.name)
except IOError: # pragma: no cover
except OSError: # pragma: no cover
info = FFMpegFilterManuallyDefined(name=filter.name)
save(info, filter.name)

Expand Down Expand Up @@ -49,5 +49,5 @@ def migrate_config() -> None: # pragma: no cover
def load_config(name: str) -> FFMpegFilterManuallyDefined | None:
try:
return load(FFMpegFilterManuallyDefined, name)
except IOError:
except OSError:
return None

0 comments on commit 5335e02

Please sign in to comment.