Skip to content

Commit

Permalink
fix mypy complaintes
Browse files Browse the repository at this point in the history
  • Loading branch information
shcheklein committed Oct 21, 2024
1 parent 6b90f53 commit 8542acc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions dvc/parsing/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ def _convert_with_meta(value, meta: Optional[Meta] = None):
return value
if isinstance(value, (list, dict)):
assert meta
container = CtxDict if isinstance(value, dict) else CtxList
return container(value, meta=meta)
if isinstance(value, dict):
return CtxDict(value, meta=meta)
return CtxList(value, meta=meta)
msg = f"Unsupported value of type '{type(value).__name__}' in '{meta}'"
raise TypeError(msg)

Expand Down
4 changes: 2 additions & 2 deletions dvc/utils/serialize/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _load_data(
):
open_fn = fs.open if fs else open
encoding = "utf-8"
with open_fn(path, encoding=encoding, **kwargs) as fd: # type: ignore[operator]
with open_fn(path, encoding=encoding, **kwargs) as fd: # type: ignore[arg-type]
with reraise(UnicodeDecodeError, EncodingError(path, encoding)):
return parser(fd.read(), path)

Expand All @@ -74,7 +74,7 @@ def _dump_data(
**dumper_args,
):
open_fn = fs.open if fs else open
with open_fn(path, "w+", encoding="utf-8") as fd: # type: ignore[operator]
with open_fn(path, "w+", encoding="utf-8") as fd: # type: ignore[call-overload]
dumper(data, fd, **dumper_args)


Expand Down

0 comments on commit 8542acc

Please sign in to comment.