Skip to content

Commit

Permalink
Deprecate audbackend.Repository (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw committed May 3, 2024
1 parent cb8a121 commit e5ef410
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
19 changes: 15 additions & 4 deletions audbackend/core/repository.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import warnings


class Repository:
r"""Repository object.
Expand All @@ -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__(
Expand All @@ -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("
Expand Down
16 changes: 16 additions & 0 deletions tests/test_repository.py
Original file line number Diff line number Diff line change
@@ -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}')"

0 comments on commit e5ef410

Please sign in to comment.