Skip to content

Commit

Permalink
black
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 f89d8a9 commit b08ef70
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions opentelemetry-api/src/opentelemetry/attributes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ def __init__(
self.max_value_len = max_value_len
# OrderedDict is not used until the maxlen is reached for efficiency.

self._dict: MutableMapping[str, types.AttributeValue] | OrderedDict[str, types.AttributeValue] = {}
self._dict: (
MutableMapping[str, types.AttributeValue]
| OrderedDict[str, types.AttributeValue]
) = {}
self._lock = threading.RLock()
if attributes:
for key, value in attributes.items():
Expand All @@ -159,7 +162,7 @@ def __init__(
def __repr__(self) -> str:
return f"{dict(self._dict)}"

def __getitem__(self, key: str)-> types.AttributeValue:
def __getitem__(self, key: str) -> types.AttributeValue:
return self._dict[key]

def __setitem__(self, key: str, value: types.AttributeValue) -> None:
Expand All @@ -179,10 +182,10 @@ def __setitem__(self, key: str, value: types.AttributeValue) -> None:
):
if not isinstance(self._dict, OrderedDict):
self._dict = OrderedDict(self._dict)
self._dict.popitem(last=False) # type: ignore
self._dict.popitem(last=False) # type: ignore
self.dropped += 1

self._dict[key] = value # type: ignore
self._dict[key] = value # type: ignore

def __delitem__(self, key: str) -> None:
if getattr(self, "_immutable", False): # type: ignore
Expand Down

0 comments on commit b08ef70

Please sign in to comment.