Skip to content

Commit

Permalink
More types.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwww committed Jan 31, 2025
1 parent 8b5f1c7 commit 213873f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions upb_lib/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def _notify(self) -> None:
observer(self, self._changeset)
self._changeset = {}

def setattr(self, attr, new_value, close_the_changeset=True):
def setattr(
self, attr: str, new_value: Any, close_the_changeset: bool = True
) -> None:
"""If attribute value has changed then set it and call the callbacks"""
existing_value = getattr(self, attr, None)
if existing_value != new_value:
Expand Down Expand Up @@ -125,7 +127,7 @@ def __init__(self, pim):
self.pim = pim
self.elements: dict[str, T] = {}

def add_element(self, element):
def add_element(self, element: T):
"""Add an element to list of elements."""
self.elements[element.index] = element

Expand All @@ -134,7 +136,7 @@ def connection_status_change(self, _):
for _, element in self.elements.items():
element._notify()

def sync(self):
def sync(self) -> None:
"""Should be overridden by derived class."""
raise NotImplementedError()

Expand Down

0 comments on commit 213873f

Please sign in to comment.