Skip to content

Commit 86103b5

Browse files
committed
Fix types
1 parent 52bb1ef commit 86103b5

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.14
2+
3+
* Minor type fixes
4+
15
## 2.0.13
26

37
* Add support for resource type and reference for client methods get/patch/delete (#133)

fhirpy/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from .lib import AsyncFHIRClient, SyncFHIRClient
22

33
__title__ = "fhir-py"
4-
__version__ = "2.0.13"
4+
__version__ = "2.0.14"
55
__author__ = "beda.software"
66
__license__ = "None"
77
__copyright__ = "Copyright 2024 beda.software"

fhirpy/base/lib_async.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ async def save(
114114
_search_params: Union[dict, None] = None,
115115
# _as_dict is a private api used internally
116116
_as_dict: bool = False,
117-
) -> Union[TResource, Any]:
117+
) -> Union[TResource, dict]:
118118
data = serialize(self.dump_resource(resource), drop_nulls_from_dicts=fields is None)
119119
if fields:
120120
if not resource.id:

fhirpy/lib.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class AsyncFHIRSearchSet(Generic[TResource], AsyncSearchSet["AsyncFHIRClient", T
2828
class BaseFHIRResource(
2929
Generic[TClient, TResource, TReference], BaseResource[TClient, TResource, TReference], ABC
3030
):
31-
def is_reference(self, value):
31+
def is_reference(self, value) -> bool:
3232
if not isinstance(value, dict):
3333
return False
3434

@@ -55,11 +55,11 @@ class BaseFHIRReference(
5555
Generic[TClient, TResource, TReference], BaseReference[TClient, TResource, TReference], ABC
5656
):
5757
@property
58-
def reference(self):
58+
def reference(self) -> str:
5959
return self["reference"]
6060

6161
@property
62-
def id(self):
62+
def id(self) -> Union[str, None]:
6363
"""
6464
Returns id if reference specifies to the local resource
6565
"""
@@ -69,7 +69,7 @@ def id(self):
6969
return None
7070

7171
@property
72-
def resource_type(self):
72+
def resource_type(self) -> Union[str, None]:
7373
"""
7474
Returns resource type if reference specifies to the local resource
7575
"""
@@ -79,7 +79,7 @@ def resource_type(self):
7979
return None
8080

8181
@property
82-
def is_local(self):
82+
def is_local(self) -> bool:
8383
return self.reference.count("/") == 1
8484

8585

@@ -98,7 +98,13 @@ class AsyncFHIRReference(
9898

9999

100100
class SyncFHIRClient(SyncClient):
101-
def reference(self, resource_type=None, id=None, reference=None, **kwargs): # noqa: A002
101+
def reference(
102+
self,
103+
resource_type=None,
104+
id=None, # noqa: A002
105+
reference=None,
106+
**kwargs,
107+
) -> SyncFHIRReference:
102108
if resource_type and id:
103109
reference = f"{resource_type}/{id}"
104110

@@ -143,7 +149,7 @@ def reference(
143149
id: Union[str, None] = None, # noqa: A002
144150
reference: Union[str, None] = None,
145151
**kwargs,
146-
):
152+
) -> AsyncFHIRReference:
147153
if resource_type and id:
148154
reference = f"{resource_type}/{id}"
149155

0 commit comments

Comments
 (0)