Skip to content

Commit 8b4021c

Browse files
committed
Even more typing fixes
1 parent 8d74262 commit 8b4021c

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ def __init__(
4343
attributes: Optional[ExtendedAttributes] = None,
4444
):
4545
attributes = attributes or {}
46-
event_attributes = {**attributes, "event.name": name}
46+
event_attributes: ExtendedAttributes = {
47+
**attributes,
48+
"event.name": name,
49+
}
4750
super().__init__(
4851
timestamp=timestamp,
4952
trace_id=trace_id,

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def _clean_attribute(
119119

120120

121121
def _clean_extended_attribute_value(
122-
value: types.AttributeValue, max_len: Optional[int]
122+
value: types.AnyValue, max_len: Optional[int]
123123
) -> types.AnyValue:
124124
# for primitive types just return the value and eventually shorten the string length
125125
if value is None or isinstance(value, _VALID_ATTR_VALUE_TYPES):
@@ -188,7 +188,7 @@ def _clean_extended_attribute_value(
188188

189189

190190
def _clean_extended_attribute(
191-
key: str, value: types.AttributeValue, max_len: Optional[int]
191+
key: str, value: types.AnyValue, max_len: Optional[int]
192192
) -> types.AnyValue:
193193
"""Checks if attribute value is valid and cleans it if required.
194194
@@ -255,8 +255,8 @@ def __init__(
255255
# OrderedDict is not used until the maxlen is reached for efficiency.
256256

257257
self._dict: Union[
258-
MutableMapping[str, types.AttributeValue],
259-
OrderedDict[str, types.AttributeValue],
258+
MutableMapping[str, types.AnyValue],
259+
OrderedDict[str, types.AnyValue],
260260
] = {}
261261
self._lock = threading.RLock()
262262
if attributes:
@@ -267,10 +267,10 @@ def __init__(
267267
def __repr__(self) -> str:
268268
return f"{dict(self._dict)}"
269269

270-
def __getitem__(self, key: str) -> types.AttributeValue:
270+
def __getitem__(self, key: str) -> types.AnyValue:
271271
return self._dict[key]
272272

273-
def __setitem__(self, key: str, value: types.AttributeValue) -> None:
273+
def __setitem__(self, key: str, value: types.AnyValue) -> None:
274274
if getattr(self, "_immutable", False): # type: ignore
275275
raise TypeError
276276
with self._lock:

0 commit comments

Comments
 (0)