Skip to content

Commit 59a7816

Browse files
committed
Fix mypy linting errors
1 parent 20ab97f commit 59a7816

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/check_jsonschema/cli/param_types.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,16 @@ def __init__(
141141
class 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)

src/check_jsonschema/schema_loader/readers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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

5555
class 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

7272
class 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)

tox.ini

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,10 @@ commands = coverage report --skip-covered
4646

4747
[testenv:mypy]
4848
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
5149
deps = mypy
5250
types-jsonschema
5351
types-requests
54-
click==8.1.3
52+
click
5553
commands = mypy src/ {posargs}
5654

5755
[testenv:pyright]

0 commit comments

Comments
 (0)