6
6
7
7
import referencing
8
8
import requests
9
- from referencing .jsonschema import DRAFT202012
9
+ from referencing .jsonschema import DRAFT202012 , Schema
10
10
11
11
from ..parsers import ParserSet
12
12
from ..utils import filename2path
@@ -18,7 +18,9 @@ def make_reference_registry(
18
18
schema_resource = referencing .Resource .from_contents (
19
19
schema , default_specification = DRAFT202012
20
20
)
21
- registry = referencing .Registry (
21
+ # mypy does not recognize that Registry is an `attrs` class and has `retrieve` as an
22
+ # argument to its implicit initializer
23
+ registry : referencing .Registry = referencing .Registry ( # type: ignore[call-arg]
22
24
retrieve = create_retrieve_callable (parsers , schema_uri )
23
25
)
24
26
@@ -34,8 +36,8 @@ def make_reference_registry(
34
36
35
37
def create_retrieve_callable (
36
38
parser_set : ParserSet , schema_uri : str | None
37
- ) -> t .Callable [[str ], referencing .Resource ]:
38
- def get_local_file (uri : str ):
39
+ ) -> t .Callable [[str ], referencing .Resource [ Schema ] ]:
40
+ def get_local_file (uri : str ) -> t . Any :
39
41
path = pathlib .Path (uri )
40
42
if not path .is_absolute ():
41
43
if schema_uri is None :
@@ -48,7 +50,7 @@ def get_local_file(uri: str):
48
50
path = schema_path .parent / path
49
51
return parser_set .parse_file (path , "json" )
50
52
51
- def retrieve_reference (uri : str ) -> referencing .Resource :
53
+ def retrieve_reference (uri : str ) -> referencing .Resource [ Schema ] :
52
54
scheme = urllib .parse .urlsplit (uri ).scheme
53
55
if scheme in ("http" , "https" ):
54
56
data = requests .get (uri , stream = True )
0 commit comments