From cee9063a03a8f233565ec9585faae80e8eba8a54 Mon Sep 17 00:00:00 2001 From: Matthew Wardrop Date: Wed, 3 Apr 2024 14:55:22 -0700 Subject: [PATCH] Migrate away from deprecated `quirk_docs` decorator. --- omniduct/caches/base.py | 4 ++-- omniduct/databases/base.py | 24 ++++++++++++------------ omniduct/duct.py | 10 +++++----- omniduct/filesystems/base.py | 34 +++++++++++++++++----------------- omniduct/remotes/base.py | 12 ++++++------ omniduct/restful/base.py | 4 ++-- omniduct/utils/magics.py | 4 ++-- pyproject.toml | 2 +- 8 files changed, 47 insertions(+), 47 deletions(-) diff --git a/omniduct/caches/base.py b/omniduct/caches/base.py index 08ce017..ff5f23c 100644 --- a/omniduct/caches/base.py +++ b/omniduct/caches/base.py @@ -6,7 +6,7 @@ import pandas import yaml from decorator import decorator -from interface_meta import quirk_docs +from interface_meta import inherit_docs from omniduct.duct import Duct from omniduct.utils.config import config @@ -134,7 +134,7 @@ class Cache(Duct): DUCT_TYPE = Duct.Type.CACHE - @quirk_docs("_init", mro=True) + @inherit_docs("_init", mro=True) def __init__(self, **kwargs): # pylint: disable=super-init-not-called Duct.__init_with_kwargs__(self, kwargs) self._init(**kwargs) diff --git a/omniduct/databases/base.py b/omniduct/databases/base.py index f1cf9da..3b8a0f9 100644 --- a/omniduct/databases/base.py +++ b/omniduct/databases/base.py @@ -11,7 +11,7 @@ import jinja2.meta import sqlparse from decorator import decorator -from interface_meta import quirk_docs, override +from interface_meta import inherit_docs, override from omniduct.caches.base import cached_method from omniduct.duct import Duct @@ -96,7 +96,7 @@ def NAMESPACE_DEFAULTS_WRITE(self): """ return self.NAMESPACE_DEFAULTS_READ - @quirk_docs("_init", mro=True) + @inherit_docs("_init", mro=True) # pylint: disable-next=super-init-not-called def __init__( self, @@ -268,7 +268,7 @@ def statement_cleanup(cls, statement): "session_properties": kwargs["session_properties"], }, ) - @quirk_docs("_execute") + @inherit_docs("_execute") @require_connection def execute( self, statement, wait=True, cursor=None, session_properties=None, **kwargs @@ -710,7 +710,7 @@ def query_from_template(self, name, context=None, **kwargs): # Uploading/querying data into data store @logging_scope("Query [CTAS]", timed=True) - @quirk_docs("_query_to_table") + @inherit_docs("_query_to_table") def query_to_table(self, statement, table, if_exists="fail", **kwargs): """ Run a query and store the results in a table in this database. @@ -734,7 +734,7 @@ def query_to_table(self, statement, table, if_exists="fail", **kwargs): return self._query_to_table(statement, table, if_exists=if_exists, **kwargs) @logging_scope("Dataframe Upload", timed=True) - @quirk_docs("_dataframe_to_table") + @inherit_docs("_dataframe_to_table") @require_connection def dataframe_to_table(self, df, table, if_exists="fail", **kwargs): """ @@ -784,7 +784,7 @@ def _parse_namespaces(self, name, level=0, defaults=None, write=False): ), ) - @quirk_docs("_table_list") + @inherit_docs("_table_list") def table_list(self, namespace=None, renew=True, **kwargs): """ Return a list of table names in the data source as a DataFrame. @@ -806,7 +806,7 @@ def table_list(self, namespace=None, renew=True, **kwargs): def _table_list(self, namespace, **kwargs): pass - @quirk_docs("_table_exists") + @inherit_docs("_table_exists") def table_exists(self, table, renew=True, **kwargs): """ Check whether a table exists. @@ -828,7 +828,7 @@ def table_exists(self, table, renew=True, **kwargs): def _table_exists(self, table, **kwargs): pass - @quirk_docs("_table_drop") + @inherit_docs("_table_drop") def table_drop(self, table, **kwargs): """ Remove a table from the database. @@ -848,7 +848,7 @@ def table_drop(self, table, **kwargs): def _table_drop(self, table, **kwargs): pass - @quirk_docs("_table_desc") + @inherit_docs("_table_desc") def table_desc(self, table, renew=True, **kwargs): """ Describe a table in the database. @@ -869,7 +869,7 @@ def table_desc(self, table, renew=True, **kwargs): def _table_desc(self, table, **kwargs): pass - @quirk_docs("_table_partition_cols") + @inherit_docs("_table_partition_cols") def table_partition_cols(self, table, renew=True, **kwargs): """ Extract the columns by which a table is partitioned (if database supports partitions). @@ -891,7 +891,7 @@ def _table_partition_cols(self, table, **kwargs): f"Database backend `{self.__class__.__name__}` does not support, or has not implemented, support for extracting partition columns." ) - @quirk_docs("_table_head") + @inherit_docs("_table_head") def table_head(self, table, n=10, renew=True, **kwargs): """ Retrieve the first `n` rows from a table. @@ -915,7 +915,7 @@ def table_head(self, table, n=10, renew=True, **kwargs): def _table_head(self, table, n=10, **kwargs): pass - @quirk_docs("_table_props") + @inherit_docs("_table_props") def table_props(self, table, renew=True, **kwargs): """ Retrieve the properties associated with a table. diff --git a/omniduct/duct.py b/omniduct/duct.py index 98cddd7..6fd08eb 100644 --- a/omniduct/duct.py +++ b/omniduct/duct.py @@ -9,7 +9,7 @@ from builtins import input from enum import Enum -from interface_meta import InterfaceMeta, quirk_docs +from interface_meta import InterfaceMeta, inherit_docs from omniduct.errors import DuctProtocolUnknown, DuctServerUnreachable from omniduct.utils.debug import logger, logging_scope @@ -261,7 +261,7 @@ def __setattr__(self, key, value): pass object.__setattr__(self, key, value) - @quirk_docs("_prepare") + @inherit_docs("_prepare") def prepare(self): """ Prepare a Duct subclass for use (if not already prepared). @@ -476,7 +476,7 @@ def __assert_server_reachable(self): # Connection @logging_scope("Connecting") - @quirk_docs("_connect") + @inherit_docs("_connect") def connect(self): """ Connect to the service backing this client. @@ -511,7 +511,7 @@ def connect(self): def _connect(self): raise NotImplementedError - @quirk_docs("_is_connected") + @inherit_docs("_is_connected") def is_connected(self): """ Check whether this `Duct` instances is currently connected. @@ -540,7 +540,7 @@ def is_connected(self): def _is_connected(self): raise NotImplementedError - @quirk_docs("_disconnect") + @inherit_docs("_disconnect") def disconnect(self): """ Disconnect this client from backing service. diff --git a/omniduct/filesystems/base.py b/omniduct/filesystems/base.py index f638818..af25a8a 100644 --- a/omniduct/filesystems/base.py +++ b/omniduct/filesystems/base.py @@ -3,7 +3,7 @@ from collections import OrderedDict, namedtuple import pandas as pd -from interface_meta import quirk_docs, override +from interface_meta import inherit_docs, override from omniduct.duct import Duct from omniduct.utils.decorators import require_connection @@ -23,7 +23,7 @@ class FileSystemClient(Duct, MagicsProvider): DUCT_TYPE = Duct.Type.FILESYSTEM DEFAULT_PORT = None - @quirk_docs("_init", mro=True) + @inherit_docs("_init", mro=True) def __init__( # pylint: disable=super-init-not-called self, cwd=None, home=None, read_only=False, global_writes=False, **kwargs ): @@ -53,7 +53,7 @@ def _init(self): # Path properties and helpers @property - @quirk_docs("_path_home") + @inherit_docs("_path_home") @require_connection def path_home(self): """ @@ -96,7 +96,7 @@ def path_cwd(self, path_cwd): self._path_cwd = path_cwd @property - @quirk_docs("_path_separator") + @inherit_docs("_path_separator") def path_separator(self): """ str: The character(s) to use in separating path components. Typically @@ -248,7 +248,7 @@ def _assert_path_is_writable(self, path): # Filesystem accessors - @quirk_docs("_exists") + @inherit_docs("_exists") @require_connection def exists(self, path): """ @@ -267,7 +267,7 @@ def exists(self, path): def _exists(self, path): raise NotImplementedError - @quirk_docs("_isdir") + @inherit_docs("_isdir") @require_connection def isdir(self, path): """ @@ -286,7 +286,7 @@ def isdir(self, path): def _isdir(self, path): raise NotImplementedError - @quirk_docs("_isfile") + @inherit_docs("_isfile") @require_connection def isfile(self, path): """ @@ -313,7 +313,7 @@ def _dir(self, path): """ raise NotImplementedError - @quirk_docs("_dir") + @inherit_docs("_dir") @require_connection def dir(self, path=None): """ @@ -386,7 +386,7 @@ def _showdir(self, path): ) return "Directory has no contents." - @quirk_docs("_walk") + @inherit_docs("_walk") @require_connection def walk(self, path=None): """ @@ -423,7 +423,7 @@ def _walk(self, path): ): # Note: using _walk directly here, which may fail if disconnected during walk. yield walked - @quirk_docs("_find") + @inherit_docs("_find") @require_connection def find(self, path_prefix=None, **attrs): """ @@ -475,7 +475,7 @@ def is_match(f): ): # Note: using _find directly here, which may fail if disconnected during find. yield match - @quirk_docs("_mkdir") + @inherit_docs("_mkdir") @require_connection def mkdir(self, path, recursive=True, exist_ok=False): """ @@ -498,7 +498,7 @@ def mkdir(self, path, recursive=True, exist_ok=False): def _mkdir(self, path, recursive, exist_ok): raise NotImplementedError - @quirk_docs("_remove") + @inherit_docs("_remove") @require_connection def remove(self, path, recursive=False): """ @@ -527,7 +527,7 @@ def _remove(self, path, recursive): # File handling - @quirk_docs("_open") + @inherit_docs("_open") @require_connection def open(self, path, mode="rt"): """ @@ -553,7 +553,7 @@ def open(self, path, mode="rt"): def _open(self, path, mode): return FileSystemFile(self, path, mode) - @quirk_docs("_file_read_") + @inherit_docs("_file_read_") @require_connection def _file_read(self, path, size=-1, offset=0, binary=False): """ @@ -577,7 +577,7 @@ def _file_read(self, path, size=-1, offset=0, binary=False): def _file_read_(self, path, size=-1, offset=0, binary=False): raise NotImplementedError - @quirk_docs("_file_write_") + @inherit_docs("_file_write_") @require_connection def _file_write(self, path, s, binary=False): """ @@ -599,7 +599,7 @@ def _file_write(self, path, s, binary=False): def _file_write_(self, path, s, binary): raise NotImplementedError - @quirk_docs("_file_append_") + @inherit_docs("_file_append_") @require_connection def _file_append(self, path, s, binary=False): """ @@ -623,7 +623,7 @@ def _file_append_(self, path, s, binary): # File transfer - @quirk_docs("_download") + @inherit_docs("_download") def download(self, source, dest=None, overwrite=False, fs=None): """ Download files to another filesystem. diff --git a/omniduct/remotes/base.py b/omniduct/remotes/base.py index 4a4d65e..c1ef8c2 100644 --- a/omniduct/remotes/base.py +++ b/omniduct/remotes/base.py @@ -2,7 +2,7 @@ import re from abc import abstractmethod -from interface_meta import quirk_docs, override +from interface_meta import inherit_docs, override from omniduct.duct import Duct from omniduct.errors import DuctAuthenticationError, DuctServerUnreachable @@ -120,7 +120,7 @@ class RemoteClient(FileSystemClient): DUCT_TYPE = Duct.Type.REMOTE DEFAULT_PORT = None - @quirk_docs("_init", mro=True) + @inherit_docs("_init", mro=True) def __init__( self, smartcards=None, **kwargs ): # pylint: disable=super-init-not-called @@ -217,7 +217,7 @@ def _prepare_smartcard(self, name, filename): return True - @quirk_docs("_execute") + @inherit_docs("_execute") @require_connection def execute(self, cmd, **kwargs): """ @@ -264,7 +264,7 @@ def _extract_host_and_ports(self, remote_host, remote_port, local_port): port = m.group("port") or remote_port return host, port, local_port - @quirk_docs("_port_forward_start") + @inherit_docs("_port_forward_start") @require_connection def port_forward(self, remote_host, remote_port=None, local_port=None): """ @@ -354,7 +354,7 @@ def has_port_forward(self, remote_host=None, remote_port=None, local_port=None): ) return self.__port_forwarding_register.reverse_lookup(local_port) is not None - @quirk_docs("_port_forward_stop") + @inherit_docs("_port_forward_stop") def port_forward_stop(self, local_port=None, remote_host=None, remote_port=None): """ Disconnect an existing port forward connection. @@ -447,7 +447,7 @@ def _port_forward_start(self, local_port, remote_host, remote_port): def _port_forward_stop(self, local_port, remote_host, remote_port, connection): raise NotImplementedError - @quirk_docs("_is_port_bound") + @inherit_docs("_is_port_bound") @require_connection def is_port_bound(self, host, port): """ diff --git a/omniduct/restful/base.py b/omniduct/restful/base.py index 69a5697..539c1f9 100644 --- a/omniduct/restful/base.py +++ b/omniduct/restful/base.py @@ -1,7 +1,7 @@ import json from urllib.parse import urljoin -from interface_meta import quirk_docs, override +from interface_meta import inherit_docs, override from omniduct.duct import Duct from omniduct.utils.decorators import require_connection @@ -29,7 +29,7 @@ class RestClientBase(Duct): DUCT_TYPE = Duct.Type.RESTFUL - @quirk_docs("_init", mro=True) + @inherit_docs("_init", mro=True) def __init__( # pylint: disable=super-init-not-called self, server_protocol="http", diff --git a/omniduct/utils/magics.py b/omniduct/utils/magics.py index 3044c4d..b7172a5 100644 --- a/omniduct/utils/magics.py +++ b/omniduct/utils/magics.py @@ -1,6 +1,6 @@ from abc import ABCMeta, abstractmethod -from interface_meta import quirk_docs +from interface_meta import inherit_docs def process_line_arguments(f): @@ -49,7 +49,7 @@ def _process_line_arguments(line_arguments): class MagicsProvider(metaclass=ABCMeta): - @quirk_docs("_register_magics") + @inherit_docs("_register_magics") def register_magics(self, base_name=None): base_name = base_name or self.name if base_name is None: diff --git a/pyproject.toml b/pyproject.toml index f733fd6..7b1981b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ classifiers = [ requires-python = ">=3.7" dependencies = [ "decorator", - "interface_meta>=1.1.0,<2", + "interface_meta>=1.2.0,<2", "jinja2", "lazy-object-proxy", "packaging",