Skip to content

Commit 8794bb3

Browse files
committed
Adjust typehinting
1 parent c050d7e commit 8794bb3

File tree

2 files changed

+8
-8
lines changed
  • opentelemetry-api/src/opentelemetry/attributes
  • opentelemetry-sdk/src/opentelemetry/sdk/resources

2 files changed

+8
-8
lines changed

opentelemetry-api/src/opentelemetry/attributes/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import threading
1717
from collections import OrderedDict
1818
from collections.abc import MutableMapping
19-
from typing import Optional, Sequence
19+
from typing import Optional, Sequence, Union
2020

2121
from opentelemetry.util import types
2222

@@ -30,7 +30,7 @@
3030

3131
def _clean_attribute(
3232
key: str, value: types.AttributeValue, max_len: Optional[int]
33-
) -> Optional[types.AttributeValue]:
33+
) -> Optional[Union[types.AttributeValue, tuple[str | int | float, ...]]]:
3434
"""Checks if attribute value is valid and cleans it if required.
3535
3636
The function returns the cleaned value or None if the value is not valid.

opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
from json import dumps
6565
from os import environ
6666
from types import ModuleType
67-
from typing import List, Optional
67+
from typing import List, Optional, Sequence, Union
6868
from urllib import parse
6969

7070
from opentelemetry.attributes import BoundedAttributes
@@ -211,11 +211,11 @@ def create(
211211

212212
if not resource.attributes.get(SERVICE_NAME, None):
213213
default_service_name = "unknown_service"
214-
process_executable_name: Optional[str] = resource.attributes.get(
214+
process_executable_name: Optional[Union[int, float, Sequence[str], Sequence[int], Sequence[float] ]] = resource.attributes.get(
215215
PROCESS_EXECUTABLE_NAME, None
216216
)
217217
if process_executable_name:
218-
default_service_name += ":" + process_executable_name
218+
default_service_name += ":" + str(process_executable_name)
219219
resource = resource.merge(
220220
Resource({SERVICE_NAME: default_service_name}, schema_url)
221221
)
@@ -250,8 +250,8 @@ def merge(self, other: "Resource") -> "Resource":
250250
Returns:
251251
The newly-created Resource.
252252
"""
253-
merged_attributes = self.attributes.copy()
254-
merged_attributes.update(other.attributes)
253+
merged_attributes = self.attributes.copy() # type: ignore
254+
merged_attributes.update(other.attributes) # type: ignore
255255

256256
if self.schema_url == "":
257257
schema_url = other.schema_url
@@ -266,7 +266,7 @@ def merge(self, other: "Resource") -> "Resource":
266266
other.schema_url,
267267
)
268268
return self
269-
return Resource(merged_attributes, schema_url)
269+
return Resource(merged_attributes, schema_url) # type: ignore
270270

271271
def __eq__(self, other: object) -> bool:
272272
if not isinstance(other, Resource):

0 commit comments

Comments
 (0)