From ce29a40618792b224fd0cc9bd6937c5fbee76c36 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 2 Aug 2023 10:37:06 +0300 Subject: Add deprecation notice to ORM-dependent `update` function Add a deprecation notice to discourage other devs from using the deprecated `update` function. --- gn3/db/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gn3') diff --git a/gn3/db/__init__.py b/gn3/db/__init__.py index 95b39d4..9a86ad8 100644 --- a/gn3/db/__init__.py +++ b/gn3/db/__init__.py @@ -1,5 +1,6 @@ # pylint: disable=[R0902, R0903] """Module that exposes common db operations""" +import logging from dataclasses import asdict, astuple from typing import Any, Dict, List, Optional, Generator, Tuple, Union from typing_extensions import Protocol @@ -17,6 +18,8 @@ from gn3.db.phenotypes import phenotype_mapping from gn3.db.phenotypes import publication_mapping from gn3.db.phenotypes import publish_x_ref_mapping +logger = logging.getLogger(__name__) + TABLEMAP = { "Phenotype": phenotype_mapping, @@ -45,6 +48,11 @@ def update(conn: Any, data: Dataclass, where: Dataclass) -> Optional[int]: """Run an UPDATE on a table""" + logger.warning( + "DEPRECATION WARNING: The function `%s.update` is deprecated and will " + "be removed soon. **DO NOT** use it, and remove all references to it " + "from your code.", + __name__) if not (any(astuple(data)) and any(astuple(where))): return None data_ = {k: v for k, v in asdict(data).items() -- cgit v1.2.3