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__(
141141class LazyBinaryReadFile (click .File ):
142142 def convert (
143143 self ,
144- value : str ,
144+ value : str | os . PathLike [ str ] | t . IO [ t . Any ] ,
145145 param : click .Parameter | None ,
146146 ctx : click .Context | None ,
147147 ) -> 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" )
149154 if ctx is not None :
150155 ctx .call_on_close (lf .close_intelligently )
151156 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:
4949 def read_schema (self ) -> dict :
5050 if self ._parsed_schema is _UNSET :
5151 self ._parsed_schema = _run_load_callback (self .filename , self ._read_impl )
52- return self ._parsed_schema
52+ return t . cast ( dict , self ._parsed_schema )
5353
5454
5555class StdinSchemaReader :
@@ -66,7 +66,7 @@ def read_schema(self) -> dict:
6666 self ._parsed_schema = json .load (sys .stdin )
6767 except ValueError as e :
6868 raise ParseError ("Failed to parse JSON from stdin" ) from e
69- return self ._parsed_schema
69+ return t . cast ( dict , self ._parsed_schema )
7070
7171
7272class HttpSchemaReader :
@@ -101,4 +101,4 @@ def _read_impl(self) -> t.Any:
101101 def read_schema (self ) -> dict :
102102 if self ._parsed_schema is _UNSET :
103103 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
4646
4747[testenv:mypy]
4848description = " 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
5149deps = mypy
5250 types-jsonschema
5351 types-requests
54- click ==8.1.3
52+ click
5553commands = mypy src/ {posargs}
5654
5755[testenv:pyright]
You can’t perform that action at this time.
0 commit comments