From e5ef41027a0812ffe3b927b07cd8e70547567d34 Mon Sep 17 00:00:00 2001 From: Hagen Wierstorf Date: Fri, 19 Apr 2024 18:19:21 +0200 Subject: [PATCH] Deprecate audbackend.Repository (#220) --- audbackend/core/repository.py | 19 +++++++++++++++---- tests/test_repository.py | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 tests/test_repository.py diff --git a/audbackend/core/repository.py b/audbackend/core/repository.py index 205586a3..27725653 100644 --- a/audbackend/core/repository.py +++ b/audbackend/core/repository.py @@ -1,3 +1,6 @@ +import warnings + + class Repository: r"""Repository object. @@ -7,15 +10,20 @@ class Repository: host, and backend. + .. Warning:: + + ``audbackend.Repository`` is deprecated + and will be removed in version 2.2.0. + If an application requires + repository objects, + that assign string names to backends, + they should be provided by the application. + Args: name: repository name host: repository host backend: repository backend - Examples: - >>> Repository("data-local", "/data", "file-system") - Repository('data-local', '/data', 'file-system') - """ def __init__( @@ -31,6 +39,9 @@ def __init__( self.backend = backend r"""Repository backend.""" + message = "Repository is deprecated and will be removed with version 2.2.0." + warnings.warn(message, category=UserWarning, stacklevel=2) + def __repr__(self): # noqa: D105 return ( f"Repository(" diff --git a/tests/test_repository.py b/tests/test_repository.py new file mode 100644 index 00000000..b394ff15 --- /dev/null +++ b/tests/test_repository.py @@ -0,0 +1,16 @@ +import pytest + +import audbackend + + +def test_repository(): + name = "name" + host = "host" + backend = "backend" + msg = "Repository is deprecated and will be removed with version 2.2.0." + with pytest.warns(UserWarning, match=msg): + repo = audbackend.Repository(name, host, backend) + assert repo.name == name + assert repo.host == host + assert repo.backend == backend + assert repo.__repr__() == f"Repository('{name}', '{host}', '{backend}')"