Skip to content

Commit 9a64c76

Browse files
authored
fix #94 detect accpet Path as input (#95)
* fix #94 detect accpet Path as input * fix #94 detect accpet Path as input * fix #94 detect accpet Path as input
1 parent ed75c1c commit 9a64c76

File tree

3 files changed

+15
-22
lines changed

3 files changed

+15
-22
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ repos:
2020
rev: 5.12.0
2121
hooks:
2222
- id: isort
23-
args: [--line-length=240, --profile=black]
23+
args: [--line-length=120, --profile=black]
2424

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

45-
- repo: local
45+
- repo: https://github.com/pre-commit/mirrors-mypy
46+
rev: v1.8.0
4647
hooks:
4748
- id: mypy
4849
name: mypy
4950
entry: mypy
50-
language: system
5151
types: [python]
52-
exclude: migrations/|commands/|scripts/
53-
args:
54-
[
55-
--pretty,
56-
--install-types,
57-
--non-interactive,
58-
--show-error-codes,
59-
--implicit-optional,
60-
--follow-imports=silent,
61-
--warn-redundant-casts,
62-
--warn-unused-ignores,
63-
--disallow-any-generics,
64-
--check-untyped-defs,
65-
--no-implicit-reexport,
66-
--disallow-untyped-defs,
67-
]
52+
exclude: migrations/|commands/|sandbox/|samples|sdk
53+
additional_dependencies: [pytest, syrupy, typer, devtools, types-requests, types-beautifulsoup4]
54+
args: [
55+
"--config-file=pyproject.toml"
56+
]

src/ffmpeg_media_type/info.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from pathlib import Path
23
from urllib.parse import urlparse
34

45
from .schema import FFMpegSupport, MediaInfo
@@ -40,7 +41,7 @@ def extract_file_extension_from_uri(uri: str) -> str:
4041
"""
4142

4243

43-
def detect(uri: str) -> MediaInfo:
44+
def detect(uri: str | Path) -> MediaInfo:
4445
"""
4546
Detect the media type of a file.
4647
@@ -53,6 +54,7 @@ def detect(uri: str) -> MediaInfo:
5354
Raises:
5455
FfmpegMediaTypeError: If the ffmpeg command fails.
5556
"""
57+
uri = str(uri)
5658
info = ffprobe(uri)
5759
current_ext = extract_file_extension_from_uri(uri)
5860

src/ffmpeg_media_type/utils/tests/test_ffprobe.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@
1212

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

0 commit comments

Comments
 (0)