Skip to content

Commit

Permalink
refactor: use getitem in descriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Feb 15, 2024
1 parent 8037e8a commit d9b32b4
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/psygnal/_group_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,12 @@ def _setattr_and_emit_(self: object, name: str, value: Any) -> None:
return super_setattr(self, name, value)

group: SignalGroup | None = getattr(self, signal_group_name, None)
signal: SignalInstance | None = getattr(group, name, None)
if not isinstance(group, SignalGroup) or name not in group:
return super_setattr(self, name, value)

# don't emit if the signal doesn't exist or has no listeners
if (
group is None
or signal is None
or len(signal) < 2
and not len(group._psygnal_relay)
):
signal: SignalInstance = group[name]
if len(signal) < 2 and not len(group._psygnal_relay):
return super_setattr(self, name, value)

with _changes_emitted(self, name, signal):
Expand Down

0 comments on commit d9b32b4

Please sign in to comment.