Skip to content

Commit a56077e

Browse files
committed
tunable: Use one lambda as listener callback
1 parent af0809a commit a56077e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

magicbot/magic_tunable.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class Component:
115115
def set_kP(self, value: float) -> None:
116116
self.pid.setP(value)
117117
"""
118-
self._update_cb = lambda inst, notif: callback(inst, notif.value.value)
118+
self._update_cb = callback
119119

120120

121121
def setup_tunables(component, cname: str, prefix: Optional[str] = "components") -> None:
@@ -160,7 +160,7 @@ def setup_tunables(component, cname: str, prefix: Optional[str] = "components")
160160
if prop._update_cb:
161161
prop._nt._api.addEntryListenerById(
162162
ntvalue._local_id,
163-
functools.partial(prop._update_cb, component),
163+
lambda notif, cb=prop._update_cb: cb(component, notif.value.value),
164164
NetworkTables.NotifyFlags.UPDATE,
165165
)
166166

0 commit comments

Comments
 (0)