From 86103b58c4376b0c84d9edec485c32c4a1bf53a9 Mon Sep 17 00:00:00 2001 From: Vadim Laletin Date: Thu, 3 Oct 2024 00:08:40 +0200 Subject: [PATCH] Fix types --- CHANGELOG.md | 4 ++++ fhirpy/__init__.py | 2 +- fhirpy/base/lib_async.py | 2 +- fhirpy/lib.py | 20 +++++++++++++------- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5465fde..4c9e824 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.14 + +* Minor type fixes + ## 2.0.13 * Add support for resource type and reference for client methods get/patch/delete (#133) diff --git a/fhirpy/__init__.py b/fhirpy/__init__.py index 48ae3cc..17b26c3 100644 --- a/fhirpy/__init__.py +++ b/fhirpy/__init__.py @@ -1,7 +1,7 @@ from .lib import AsyncFHIRClient, SyncFHIRClient __title__ = "fhir-py" -__version__ = "2.0.13" +__version__ = "2.0.14" __author__ = "beda.software" __license__ = "None" __copyright__ = "Copyright 2024 beda.software" diff --git a/fhirpy/base/lib_async.py b/fhirpy/base/lib_async.py index dbe65b3..45434d7 100644 --- a/fhirpy/base/lib_async.py +++ b/fhirpy/base/lib_async.py @@ -114,7 +114,7 @@ async def save( _search_params: Union[dict, None] = None, # _as_dict is a private api used internally _as_dict: bool = False, - ) -> Union[TResource, Any]: + ) -> Union[TResource, dict]: data = serialize(self.dump_resource(resource), drop_nulls_from_dicts=fields is None) if fields: if not resource.id: diff --git a/fhirpy/lib.py b/fhirpy/lib.py index 6c605ec..f31e5f6 100644 --- a/fhirpy/lib.py +++ b/fhirpy/lib.py @@ -28,7 +28,7 @@ class AsyncFHIRSearchSet(Generic[TResource], AsyncSearchSet["AsyncFHIRClient", T class BaseFHIRResource( Generic[TClient, TResource, TReference], BaseResource[TClient, TResource, TReference], ABC ): - def is_reference(self, value): + def is_reference(self, value) -> bool: if not isinstance(value, dict): return False @@ -55,11 +55,11 @@ class BaseFHIRReference( Generic[TClient, TResource, TReference], BaseReference[TClient, TResource, TReference], ABC ): @property - def reference(self): + def reference(self) -> str: return self["reference"] @property - def id(self): + def id(self) -> Union[str, None]: """ Returns id if reference specifies to the local resource """ @@ -69,7 +69,7 @@ def id(self): return None @property - def resource_type(self): + def resource_type(self) -> Union[str, None]: """ Returns resource type if reference specifies to the local resource """ @@ -79,7 +79,7 @@ def resource_type(self): return None @property - def is_local(self): + def is_local(self) -> bool: return self.reference.count("/") == 1 @@ -98,7 +98,13 @@ class AsyncFHIRReference( class SyncFHIRClient(SyncClient): - def reference(self, resource_type=None, id=None, reference=None, **kwargs): # noqa: A002 + def reference( + self, + resource_type=None, + id=None, # noqa: A002 + reference=None, + **kwargs, + ) -> SyncFHIRReference: if resource_type and id: reference = f"{resource_type}/{id}" @@ -143,7 +149,7 @@ def reference( id: Union[str, None] = None, # noqa: A002 reference: Union[str, None] = None, **kwargs, - ): + ) -> AsyncFHIRReference: if resource_type and id: reference = f"{resource_type}/{id}"