Skip to content

Commit f432e04

Browse files
authored
Type endpoint_id and path_parts as Optional (#156)
1 parent 989099a commit f432e04

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

elastic_transport/_async_transport.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ async def perform_request( # type: ignore[override]
186186
retry_on_timeout: Union[bool, DefaultType] = DEFAULT,
187187
request_timeout: Union[Optional[float], DefaultType] = DEFAULT,
188188
client_meta: Union[Tuple[Tuple[str, str], ...], DefaultType] = DEFAULT,
189-
endpoint_id: Union[str, DefaultType] = DEFAULT,
190-
path_parts: Union[Mapping[str, str], DefaultType] = DEFAULT,
189+
endpoint_id: Optional[str] = None,
190+
path_parts: Optional[Mapping[str, str]] = None,
191191
) -> TransportApiResponse:
192192
"""
193193
Perform the actual request. Retrieve a node from the node
@@ -217,10 +217,11 @@ async def perform_request( # type: ignore[override]
217217
Used for OpenTelemetry instrumentation.
218218
:returns: Tuple of the :class:`elastic_transport.ApiResponseMeta` with the deserialized response.
219219
"""
220+
path_parts = path_parts if path_parts is not None else {}
220221
with self.otel.span(
221222
method,
222-
endpoint_id=resolve_default(endpoint_id, None),
223-
path_parts=resolve_default(path_parts, {}),
223+
endpoint_id=endpoint_id,
224+
path_parts=path_parts,
224225
) as otel_span:
225226
response = await self._perform_request(
226227
method,

elastic_transport/_transport.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ def perform_request(
268268
retry_on_timeout: Union[bool, DefaultType] = DEFAULT,
269269
request_timeout: Union[Optional[float], DefaultType] = DEFAULT,
270270
client_meta: Union[Tuple[Tuple[str, str], ...], DefaultType] = DEFAULT,
271-
endpoint_id: Union[str, DefaultType] = DEFAULT,
272-
path_parts: Union[Mapping[str, str], DefaultType] = DEFAULT,
271+
endpoint_id: Optional[str] = None,
272+
path_parts: Optional[Mapping[str, str]] = None,
273273
) -> TransportApiResponse:
274274
"""
275275
Perform the actual request. Retrieve a node from the node
@@ -299,10 +299,11 @@ def perform_request(
299299
Used for OpenTelemetry instrumentation.
300300
:returns: Tuple of the :class:`elastic_transport.ApiResponseMeta` with the deserialized response.
301301
"""
302+
path_parts = path_parts if path_parts is not None else {}
302303
with self.otel.span(
303304
method,
304-
endpoint_id=resolve_default(endpoint_id, None),
305-
path_parts=resolve_default(path_parts, {}),
305+
endpoint_id=endpoint_id,
306+
path_parts=path_parts,
306307
) as otel_span:
307308
response = self._perform_request(
308309
method,

0 commit comments

Comments
 (0)