File tree Expand file tree Collapse file tree 3 files changed +11
-8
lines changed Expand file tree Collapse file tree 3 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -141,11 +141,16 @@ def __init__(
141
141
class LazyBinaryReadFile (click .File ):
142
142
def convert (
143
143
self ,
144
- value : str ,
144
+ value : str | os . PathLike [ str ] | t . IO [ t . Any ] ,
145
145
param : click .Parameter | None ,
146
146
ctx : click .Context | None ,
147
147
) -> t .IO [bytes ]:
148
- lf = _CustomLazyFile (value , mode = "rb" )
148
+ if hasattr (value , "read" ) or hasattr (value , "write" ):
149
+ return t .cast (t .IO [bytes ], value )
150
+
151
+ value_ : str | os .PathLike [str ] = t .cast ("str | os.PathLike[str]" , value )
152
+
153
+ lf = _CustomLazyFile (value_ , mode = "rb" )
149
154
if ctx is not None :
150
155
ctx .call_on_close (lf .close_intelligently )
151
156
return t .cast (t .IO [bytes ], lf )
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ def _read_impl(self) -> t.Any:
49
49
def read_schema (self ) -> dict :
50
50
if self ._parsed_schema is _UNSET :
51
51
self ._parsed_schema = _run_load_callback (self .filename , self ._read_impl )
52
- return self ._parsed_schema
52
+ return t . cast ( dict , self ._parsed_schema )
53
53
54
54
55
55
class StdinSchemaReader :
@@ -66,7 +66,7 @@ def read_schema(self) -> dict:
66
66
self ._parsed_schema = json .load (sys .stdin )
67
67
except ValueError as e :
68
68
raise ParseError ("Failed to parse JSON from stdin" ) from e
69
- return self ._parsed_schema
69
+ return t . cast ( dict , self ._parsed_schema )
70
70
71
71
72
72
class HttpSchemaReader :
@@ -101,4 +101,4 @@ def _read_impl(self) -> t.Any:
101
101
def read_schema (self ) -> dict :
102
102
if self ._parsed_schema is _UNSET :
103
103
self ._parsed_schema = _run_load_callback (self .url , self ._read_impl )
104
- return self ._parsed_schema
104
+ return t . cast ( dict , self ._parsed_schema )
Original file line number Diff line number Diff line change @@ -46,12 +46,10 @@ commands = coverage report --skip-covered
46
46
47
47
[testenv:mypy]
48
48
description = " check type annotations with mypy"
49
- # temporarily pin back click until either click 8.1.5 releases or mypy fixes the issue
50
- # with referential integrity of type aliases
51
49
deps = mypy
52
50
types-jsonschema
53
51
types-requests
54
- click ==8.1.3
52
+ click
55
53
commands = mypy src/ {posargs}
56
54
57
55
[testenv:pyright]
You can’t perform that action at this time.
0 commit comments