diff --git a/dvc/parsing/context.py b/dvc/parsing/context.py index 3d7beeec6..af8d1b3fd 100644 --- a/dvc/parsing/context.py +++ b/dvc/parsing/context.py @@ -176,8 +176,9 @@ class Container(Node, ABC): 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) diff --git a/dvc/utils/serialize/_common.py b/dvc/utils/serialize/_common.py index fde893343..e9eafd513 100644 --- a/dvc/utils/serialize/_common.py +++ b/dvc/utils/serialize/_common.py @@ -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) @@ -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) diff --git a/pyproject.toml b/pyproject.toml index ac5fdfe14..dc36d1f9c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -83,7 +83,7 @@ gdrive = ["dvc-gdrive>=3,<4"] gs = ["dvc-gs>=3,<4"] hdfs = ["dvc-hdfs>=3,<4"] lint = [ - "mypy==1.11.2", + "mypy==1.12.0", "pandas-stubs", "types-colorama", "types-psutil",