diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 02b0c1e..a39415f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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" + ] diff --git a/src/ffmpeg_media_type/info.py b/src/ffmpeg_media_type/info.py index 08cac01..85dcb25 100644 --- a/src/ffmpeg_media_type/info.py +++ b/src/ffmpeg_media_type/info.py @@ -1,4 +1,5 @@ import os +from pathlib import Path from urllib.parse import urlparse from .schema import FFMpegSupport, MediaInfo @@ -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. @@ -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) diff --git a/src/ffmpeg_media_type/utils/tests/test_ffprobe.py b/src/ffmpeg_media_type/utils/tests/test_ffprobe.py index 16e05d3..d1eecb4 100644 --- a/src/ffmpeg_media_type/utils/tests/test_ffprobe.py +++ b/src/ffmpeg_media_type/utils/tests/test_ffprobe.py @@ -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()))) + )