Skip to content

Commit

Permalink
Adjust typehinting
Browse files Browse the repository at this point in the history
  • Loading branch information
asasvari authored and attila-s committed Jul 19, 2024
1 parent 3e36b69 commit 55ce61d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions opentelemetry-api/src/opentelemetry/attributes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import threading
from collections import OrderedDict
from collections.abc import MutableMapping
from typing import Optional, Sequence
from typing import Optional, Sequence, Union

from opentelemetry.util import types

Expand All @@ -30,7 +30,7 @@

def _clean_attribute(
key: str, value: types.AttributeValue, max_len: Optional[int]
) -> Optional[types.AttributeValue]:
) -> Optional[Union[types.AttributeValue, tuple[str | int | float, ...]]]:
"""Checks if attribute value is valid and cleans it if required.
The function returns the cleaned value or None if the value is not valid.
Expand Down
12 changes: 6 additions & 6 deletions opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
from json import dumps
from os import environ
from types import ModuleType
from typing import List, Optional
from typing import List, Optional, Sequence, Union
from urllib import parse

from opentelemetry.attributes import BoundedAttributes
Expand Down Expand Up @@ -211,11 +211,11 @@ def create(

if not resource.attributes.get(SERVICE_NAME, None):
default_service_name = "unknown_service"
process_executable_name: Optional[str] = resource.attributes.get(
process_executable_name: Optional[Union[int, float, Sequence[str], Sequence[int], Sequence[float] ]] = resource.attributes.get(
PROCESS_EXECUTABLE_NAME, None
)
if process_executable_name:
default_service_name += ":" + process_executable_name
default_service_name += ":" + str(process_executable_name)
resource = resource.merge(
Resource({SERVICE_NAME: default_service_name}, schema_url)
)
Expand Down Expand Up @@ -250,8 +250,8 @@ def merge(self, other: "Resource") -> "Resource":
Returns:
The newly-created Resource.
"""
merged_attributes = self.attributes.copy()
merged_attributes.update(other.attributes)
merged_attributes = self.attributes.copy() # type: ignore
merged_attributes.update(other.attributes) # type: ignore

if self.schema_url == "":
schema_url = other.schema_url
Expand All @@ -266,7 +266,7 @@ def merge(self, other: "Resource") -> "Resource":
other.schema_url,
)
return self
return Resource(merged_attributes, schema_url)
return Resource(merged_attributes, schema_url) # type: ignore

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

0 comments on commit 55ce61d

Please sign in to comment.