From cc07310e62d38b56753ee2e96da5085e1e9ee9a9 Mon Sep 17 00:00:00 2001 From: Dimitri Yatsenko Date: Sat, 18 Jul 2026 11:32:01 -0500 Subject: [PATCH] chore: normalize stdlib copy imports to `import copy` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three modules used three conventions for the copy module: diagram.py `import copy as copy_module`, settings.py `from copy import deepcopy`, expression.py `import copy`. Standardize on plain `import copy` with qualified `copy.deepcopy` / `copy.copy` — one import covers both shallow and deep copies, and the diagram.py alias was unnecessary (`copy` there only appears as a keyword argument, which can't collide with the module name). No behavior change. --- src/datajoint/diagram.py | 8 ++++---- src/datajoint/settings.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/datajoint/diagram.py b/src/datajoint/diagram.py index 455a0015a..c4d014ef0 100644 --- a/src/datajoint/diagram.py +++ b/src/datajoint/diagram.py @@ -15,7 +15,7 @@ from __future__ import annotations -import copy as copy_module +import copy import functools import inspect import io @@ -103,9 +103,9 @@ def __init__(self, source, context=None) -> None: self._expanded_nodes = set(source._expanded_nodes) self.context = source.context self._connection = source._connection - self._cascade_restrictions = copy_module.deepcopy(source._cascade_restrictions) - self._restrict_conditions = copy_module.deepcopy(source._restrict_conditions) - self._restriction_attrs = copy_module.deepcopy(source._restriction_attrs) + self._cascade_restrictions = copy.deepcopy(source._cascade_restrictions) + self._restrict_conditions = copy.deepcopy(source._restrict_conditions) + self._restriction_attrs = copy.deepcopy(source._restriction_attrs) super().__init__(source) return diff --git a/src/datajoint/settings.py b/src/datajoint/settings.py index a0a5c12a5..9bcce0201 100644 --- a/src/datajoint/settings.py +++ b/src/datajoint/settings.py @@ -37,12 +37,12 @@ from __future__ import annotations +import copy import json import logging import os import warnings from contextlib import contextmanager -from copy import deepcopy from enum import Enum from pathlib import Path from typing import Any, Iterator, Literal @@ -805,14 +805,14 @@ def override(self, **kwargs: Any) -> Iterator["Config"]: if len(key_parts) == 1: key = key_parts[0] if hasattr(self, key): - backup[key_parts] = deepcopy(getattr(self, key)) + backup[key_parts] = copy.deepcopy(getattr(self, key)) setattr(self, key, value) elif len(key_parts) == 2: group, attr = key_parts if hasattr(self, group): group_obj = getattr(self, group) if hasattr(group_obj, attr): - backup[key_parts] = deepcopy(getattr(group_obj, attr)) + backup[key_parts] = copy.deepcopy(getattr(group_obj, attr)) setattr(group_obj, attr, value) yield self