diff --git a/CHANGELOG.md b/CHANGELOG.md index 32988f1..71d6de1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2.0.1 +* Fix backward compatibility for client resource/resources + ## 2.0.0 * Add typehints for all methods * Add pluggable data model #126 diff --git a/fhirpy/__init__.py b/fhirpy/__init__.py index 7221683..56ba443 100644 --- a/fhirpy/__init__.py +++ b/fhirpy/__init__.py @@ -1,7 +1,7 @@ from .lib import AsyncFHIRClient, SyncFHIRClient __title__ = "fhir-py" -__version__ = "2.0.0" +__version__ = "2.0.1" __author__ = "beda.software" __license__ = "None" __copyright__ = "Copyright 2024 beda.software" diff --git a/fhirpy/base/client.py b/fhirpy/base/client.py index 2bc53f3..db2f74e 100644 --- a/fhirpy/base/client.py +++ b/fhirpy/base/client.py @@ -1,3 +1,4 @@ +import warnings from abc import ABC, abstractmethod from typing import Any, TypeVar, Union @@ -14,6 +15,16 @@ class AbstractClient(ABC): authorization: Union[str, None] extra_headers: Union[dict, None] + # Deprecated + @property # pragma: no cover + def searchset_class(self): + raise NotImplementedError() + + # Deprecated + @property # pragma: no cover + def resource_class(self): + raise NotImplementedError() + def __init__( self, url: str, @@ -34,13 +45,27 @@ def __repr__(self): def reference(self, resource_type=None, id=None, reference=None, **kwargs): # noqa: A002 pass - @abstractmethod - def resource(self, resource_type, **kwargs): - pass - - @abstractmethod - def resources(self, resource_type): - pass + def resource(self, resource_type, **kwargs): # pragma: no cover + warnings.warn( + "class var `resource_class` is deprecated " + "and will be removed in future versions. " + "Please redefine `resource` method of client", + DeprecationWarning, + stacklevel=2, + ) + + return self.resource_class(self, resource_type=resource_type, **kwargs) + + def resources(self, resource_type): # pragma: no cover + warnings.warn( + "class var `searchset_class` is deprecated " + "and will be removed in future versions. " + "Please redefine `resource` method of client", + DeprecationWarning, + stacklevel=2, + ) + + return self.searchset_class(self, resource_type=resource_type) @abstractmethod def execute(