1- from collections import Counter
21import itertools
32import typing as ty
3+ from collections import Counter
44from pathlib import Path
5+
56import pytest
6- from fileformats .core import (
7- find_matching ,
8- to_mime ,
9- from_mime ,
10- from_paths ,
11- FileSet ,
12- )
13- from fileformats .generic import File , SetOf
14- from fileformats .core .exceptions import FormatRecognitionError
15- from fileformats .testing import Foo , Bar
7+
8+ import fileformats .text
169from fileformats .application import Json , Yaml , Zip
10+ from fileformats .core import FileSet , find_matching , from_mime , from_paths , to_mime
11+ from fileformats .core .exceptions import FormatRecognitionError
12+ from fileformats .generic import File , SetOf
13+ from fileformats .testing import Bar , Foo
1714from fileformats .text import Plain , TextFile
18- import fileformats .text
1915
2016
21- def test_format_detection (work_dir ):
17+ def test_format_detection (work_dir ) -> None :
2218 text_file = work_dir / "text.txt"
2319
2420 with open (text_file , "w" ) as f :
@@ -32,41 +28,41 @@ def test_format_detection(work_dir):
3228 ]
3329
3430
35- def test_to_from_mime_roundtrip ():
31+ def test_to_from_mime_roundtrip () -> None :
3632 mime_str = to_mime (Foo , official = False )
3733 assert isinstance (mime_str , str )
3834 assert from_mime (mime_str ) == Foo
3935
4036
41- def test_to_from_list_mime_roundtrip ():
37+ def test_to_from_list_mime_roundtrip () -> None :
4238 mime_str = to_mime (ty .List [Foo ], official = False )
4339 assert isinstance (mime_str , str )
4440 assert from_mime (mime_str ) == ty .List [Foo ]
4541
4642
47- def test_to_from_union_mime_roundtrip ():
43+ def test_to_from_union_mime_roundtrip () -> None :
4844 mime_str = to_mime (ty .Union [Foo , Bar ], official = False )
4945 assert isinstance (mime_str , str )
5046 assert from_mime (mime_str ) == ty .Union [Foo , Bar ]
5147
5248
53- def test_to_from_list_union_mime_roundtrip ():
49+ def test_to_from_list_union_mime_roundtrip () -> None :
5450 mime_str = to_mime (ty .List [ty .Union [Foo , Bar ]], official = False )
5551 assert isinstance (mime_str , str )
5652 assert from_mime (mime_str ) == ty .List [ty .Union [Foo , Bar ]]
5753
5854
59- def test_official_mime_fail ():
55+ def test_official_mime_fail () -> None :
6056 with pytest .raises (TypeError , match = "as it is not a proper file-type" ):
6157 to_mime (ty .List [Foo ], official = True )
6258
6359
64- def test_repr ():
60+ def test_repr () -> None :
6561 for frmt in FileSet .all_formats :
6662 assert repr (frmt .mock ("/a/path" )).startswith (f"{ frmt .__name__ } (" )
6763
6864
69- def test_set_repr_trunc ():
65+ def test_set_repr_trunc () -> None :
7066 a = Path ("/a/path" ).absolute ()
7167 b = Path ("/b/path" ).absolute ()
7268 c = Path ("/c/path" ).absolute ()
@@ -76,7 +72,7 @@ def test_set_repr_trunc():
7672 )
7773
7874
79- def test_from_paths (tmp_path ):
75+ def test_from_paths (tmp_path ) -> None :
8076 filesets = []
8177 filesets .append (Json .sample (tmp_path , seed = 1 ))
8278 filesets .append (Json .sample (tmp_path , seed = 2 ))
0 commit comments