Skip to content

Commit

Permalink
fix #94 detect accpet Path as input (#95)
Browse files Browse the repository at this point in the history
* fix #94 detect accpet Path as input

* fix #94 detect accpet Path as input

* fix #94 detect accpet Path as input
  • Loading branch information
lucemia authored May 14, 2024
1 parent ed75c1c commit 9a64c76
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
29 changes: 9 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
rev: 5.12.0
hooks:
- id: isort
args: [--line-length=240, --profile=black]
args: [--line-length=120, --profile=black]

# this is slightly dangerous because python imports have side effects
# and this tool removes unused imports, which may be providing
Expand All @@ -40,28 +40,17 @@ repos:
rev: 22.8.0
hooks:
- id: black
args: [--line-length=240, --exclude=""]
args: [--line-length=120, --exclude=""]

- repo: local
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
name: mypy
entry: mypy
language: system
types: [python]
exclude: migrations/|commands/|scripts/
args:
[
--pretty,
--install-types,
--non-interactive,
--show-error-codes,
--implicit-optional,
--follow-imports=silent,
--warn-redundant-casts,
--warn-unused-ignores,
--disallow-any-generics,
--check-untyped-defs,
--no-implicit-reexport,
--disallow-untyped-defs,
]
exclude: migrations/|commands/|sandbox/|samples|sdk
additional_dependencies: [pytest, syrupy, typer, devtools, types-requests, types-beautifulsoup4]
args: [
"--config-file=pyproject.toml"
]
4 changes: 3 additions & 1 deletion src/ffmpeg_media_type/info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from pathlib import Path
from urllib.parse import urlparse

from .schema import FFMpegSupport, MediaInfo
Expand Down Expand Up @@ -40,7 +41,7 @@ def extract_file_extension_from_uri(uri: str) -> str:
"""


def detect(uri: str) -> MediaInfo:
def detect(uri: str | Path) -> MediaInfo:
"""
Detect the media type of a file.
Expand All @@ -53,6 +54,7 @@ def detect(uri: str) -> MediaInfo:
Raises:
FfmpegMediaTypeError: If the ffmpeg command fails.
"""
uri = str(uri)
info = ffprobe(uri)
current_ext = extract_file_extension_from_uri(uri)

Expand Down
4 changes: 3 additions & 1 deletion src/ffmpeg_media_type/utils/tests/test_ffprobe.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@

@pytest.mark.parametrize("case", sample_test_media_files())
def test_ffprobe_file(case: Path, snapshot: SnapshotAssertion) -> None:
assert snapshot(extension_class=JSONSnapshotExtension, exclude=paths("format.filename")) == asdict(ffprobe(str(case.relative_to(Path.cwd()))))
assert snapshot(extension_class=JSONSnapshotExtension, exclude=paths("format.filename")) == asdict(
ffprobe(str(case.relative_to(Path.cwd())))
)

0 comments on commit 9a64c76

Please sign in to comment.