diff --git a/dvc/api/show.py b/dvc/api/show.py index bbf92a27b..7b91123d1 100644 --- a/dvc/api/show.py +++ b/dvc/api/show.py @@ -25,7 +25,7 @@ def _postprocess(results): (k if counts[k] == 1 else f"{file_name}:{k}"): v for k, v in file_data["data"].items() } - processed[rev] = {**processed[rev], **to_merge} + processed[rev] = processed[rev] | to_merge if "workspace" in processed: del processed["workspace"] diff --git a/dvc/config_schema.py b/dvc/config_schema.py index 206a8b652..503e90c7f 100644 --- a/dvc/config_schema.py +++ b/dvc/config_schema.py @@ -181,7 +181,7 @@ SCHEMA = { "remote": { str: ByUrl( { - "": {**LOCAL_COMMON, **REMOTE_COMMON}, + "": LOCAL_COMMON | REMOTE_COMMON, "s3": { "region": str, "profile": str, @@ -285,10 +285,10 @@ SCHEMA = { Optional("verify", default=True): Bool, **REMOTE_COMMON, }, - "http": {**HTTP_COMMON, **REMOTE_COMMON}, - "https": {**HTTP_COMMON, **REMOTE_COMMON}, - "webdav": {**WEBDAV_COMMON, **REMOTE_COMMON}, - "webdavs": {**WEBDAV_COMMON, **REMOTE_COMMON}, + "http": HTTP_COMMON | REMOTE_COMMON, + "https": HTTP_COMMON | REMOTE_COMMON, + "webdav": WEBDAV_COMMON | REMOTE_COMMON, + "webdavs": WEBDAV_COMMON | REMOTE_COMMON, "remote": {str: object}, # Any of the above options are valid } ) diff --git a/dvc/fs/__init__.py b/dvc/fs/__init__.py index 4da05d000..53812359e 100644 --- a/dvc/fs/__init__.py +++ b/dvc/fs/__init__.py @@ -158,5 +158,5 @@ def get_cloud_fs(repo_config, **kwargs): fs_path = cls._strip_protocol(url) extras = cls._get_kwargs_from_urls(url) - conf = {**extras, **remote_conf} # remote config takes priority + conf = extras | remote_conf # remote config takes priority return cls, conf, fs_path diff --git a/dvc/output.py b/dvc/output.py index 4ca5bd765..e94dd00e8 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -1478,7 +1478,7 @@ META_SCHEMA = { Meta.PARAM_VERSION_ID: str, } -CLOUD_SCHEMA = vol.All({str: {**META_SCHEMA, **CHECKSUMS_SCHEMA}}, vol.Length(max=1)) +CLOUD_SCHEMA = vol.All({str: META_SCHEMA | CHECKSUMS_SCHEMA}, vol.Length(max=1)) ARTIFACT_SCHEMA: dict[Any, Any] = { **CHECKSUMS_SCHEMA, diff --git a/dvc/progress.py b/dvc/progress.py index 81b7a9f7b..4ed6750b3 100644 --- a/dvc/progress.py +++ b/dvc/progress.py @@ -68,7 +68,7 @@ class Tqdm(tqdm): """ kwargs = kwargs.copy() if bytes: - kwargs = {**self.BYTES_DEFAULTS, **kwargs} + kwargs = self.BYTES_DEFAULTS | kwargs else: kwargs.setdefault("unit_scale", total > 999 if total else True) if file is None: diff --git a/dvc/render/converter/vega.py b/dvc/render/converter/vega.py index 82db62c67..48f5843c0 100644 --- a/dvc/render/converter/vega.py +++ b/dvc/render/converter/vega.py @@ -285,7 +285,7 @@ class VegaConverter(Converter): if not all_datapoints: return [], {} - properties = {**properties, **props_update} + properties = properties | props_update return all_datapoints, properties @@ -298,7 +298,7 @@ class VegaConverter(Converter): inferred_properties = self._infer_x_y() datapoints = self._find_datapoints() - properties = {**self.properties, **inferred_properties} + properties = self.properties | inferred_properties properties["y_label"] = self.infer_y_label(properties) properties["x_label"] = self.infer_x_label(properties) diff --git a/dvc/render/match.py b/dvc/render/match.py index dbb710b2c..e47d203a5 100644 --- a/dvc/render/match.py +++ b/dvc/render/match.py @@ -25,7 +25,7 @@ def _squash_plots_properties(data: list) -> dict: configs = [last(group) for group in data] resolved: dict = {} for config in reversed(configs): - resolved = {**resolved, **config} + resolved = resolved | config return resolved diff --git a/dvc/repo/experiments/executor/base.py b/dvc/repo/experiments/executor/base.py index 0ba541c2d..22c7ee3d4 100644 --- a/dvc/repo/experiments/executor/base.py +++ b/dvc/repo/experiments/executor/base.py @@ -614,7 +614,7 @@ class BaseExecutor(ABC): # set missing config options using saved config # inferring repo url will fail if not set here run_env_config = env_to_config(kwargs.get("run_env", {})) - dvc_studio_config = {**run_env_config, **dvc_studio_config} + dvc_studio_config = run_env_config | dvc_studio_config try: post_live_metrics( "start", diff --git a/dvc/repo/experiments/queue/base.py b/dvc/repo/experiments/queue/base.py index 0296a85c7..742b11348 100644 --- a/dvc/repo/experiments/queue/base.py +++ b/dvc/repo/experiments/queue/base.py @@ -337,7 +337,7 @@ class BaseStashQueue(ABC): studio_config = get_studio_config( dvc_studio_config=self.repo.config.get("studio") ) - run_env = {**config_to_env(studio_config), **run_env} + run_env = config_to_env(studio_config) | run_env self._pack_args(*args, run_env=run_env, **kwargs) # save experiment as a stash commit msg = self._stash_msg( diff --git a/dvc/repo/experiments/show.py b/dvc/repo/experiments/show.py index 50b11be6c..16ab9b38f 100644 --- a/dvc/repo/experiments/show.py +++ b/dvc/repo/experiments/show.py @@ -77,7 +77,7 @@ def tabulate( "State", "Executor", ] - names = {**metrics_names, **params_names} + names = metrics_names | params_names counter = Counter(flatten_list([list(a.keys()) for a in names.values()])) counter.update(headers) metrics_headers = _normalize_headers(metrics_names, counter) diff --git a/dvc/repo/plots/__init__.py b/dvc/repo/plots/__init__.py index 605a07183..ee783d25d 100644 --- a/dvc/repo/plots/__init__.py +++ b/dvc/repo/plots/__init__.py @@ -171,7 +171,7 @@ class Plots: plots = _collect_plots(repo, targets, recursive) res: dict[str, Any] = {} for fs_path, rev_props in plots.items(): - joined_props = {**rev_props, **props} + joined_props = rev_props | props res[fs_path] = {"props": joined_props} res[fs_path].update( { @@ -405,7 +405,7 @@ def _collect_output_plots(repo, targets, props, onerror: Optional[Callable] = No unpacked = unpack_if_dir( fs, _normpath(fs.join(wdir_relpath, plot.def_path)), - props={**plot_props, **props}, + props=plot_props | props, onerror=onerror, ) @@ -449,12 +449,12 @@ def _resolve_definitions( data_path = _normpath(fs.join(config_dir, plot_id)) if _matches(targets, config_path, plot_id): unpacked = unpack_if_dir( - fs, data_path, props={**plot_props, **props}, onerror=onerror + fs, data_path, props=plot_props | props, onerror=onerror ) dpath.merge(result, unpacked) elif _matches(targets, config_path, plot_id): adjusted_props = _adjust_sources(fs, plot_props, config_dir) - dpath.merge(result, {"data": {plot_id: {**adjusted_props, **props}}}) + dpath.merge(result, {"data": {plot_id: adjusted_props | props}}) return result diff --git a/dvc/schema.py b/dvc/schema.py index 5695a1b41..37710ad3b 100644 --- a/dvc/schema.py +++ b/dvc/schema.py @@ -71,7 +71,7 @@ PLOT_PROPS = { Output.PARAM_PLOT_TITLE: str, Output.PARAM_PLOT_HEADER: bool, } -PLOT_PROPS_SCHEMA = {**OUT_PSTAGE_DETAILED_SCHEMA[str], **PLOT_PROPS} +PLOT_PROPS_SCHEMA = OUT_PSTAGE_DETAILED_SCHEMA[str] | PLOT_PROPS PLOT_PSTAGE_SCHEMA = {str: vol.Any(PLOT_PROPS_SCHEMA, [PLOT_PROPS_SCHEMA])} PARAM_PSTAGE_NON_DEFAULT_SCHEMA = {str: [str]} diff --git a/tests/utils/asserts.py b/tests/utils/asserts.py index f7ae07452..2ea17f526 100644 --- a/tests/utils/asserts.py +++ b/tests/utils/asserts.py @@ -6,7 +6,7 @@ if TYPE_CHECKING: def issubset(subset: dict, superset: dict) -> bool: - assert superset == {**superset, **subset} + assert superset == superset | subset return True