Skip to content

Commit

Permalink
Fix some type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Feb 28, 2024
1 parent d9d7189 commit 63b304d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 6 additions & 3 deletions auto_editor/ffwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,13 @@ def initFileInfo(path: str, ffmpeg: FFmpeg, log: Log) -> FileInfo:
log.debug("Unexpected ffprobe shape")

if v.sample_aspect_ratio is None:
try:
sar = Fraction(_sar.replace(":", "/"))
except Exception:
if _sar is None:
sar = Fraction(1)
else:
try:
sar = Fraction(_sar.replace(":", "/"))
except Exception:
sar = Fraction(1)
else:
sar = v.sample_aspect_ratio

Expand Down
7 changes: 5 additions & 2 deletions auto_editor/lang/palet.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def initOutPort(name: str) -> OutputPort | Literal[False]:
return OutputPort(name, port, port.write, False)


def raise_(msg: str) -> NoReturn:
def raise_(msg: str | Exception) -> NoReturn:
raise MyError(msg)


Expand Down Expand Up @@ -1470,7 +1470,10 @@ def edit_all() -> np.ndarray:


def edit_audio(
threshold: float = 0.04, stream: object = Sym("all"), mincut: int = 6, minclip: int = 3
threshold: float = 0.04,
stream: object = Sym("all"),
mincut: int = 6,
minclip: int = 3,
) -> np.ndarray:
if "@levels" not in env or "@filesetup" not in env:
raise MyError("Can't use `audio` if there's no input media")
Expand Down
1 change: 1 addition & 0 deletions auto_editor/render/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def make_image_cache(tl: v3) -> dict[tuple[FileInfo, int], np.ndarray]:
for obj in clip:
if isinstance(obj, TlImage) and obj.src not in img_cache:
with av.open(obj.src.path) as cn:
assert isinstance(cn, av.InputContainer)
my_stream = cn.streams.video[0]
for frame in cn.decode(my_stream):
if obj.width != 0:
Expand Down

0 comments on commit 63b304d

Please sign in to comment.