Skip to content

Commit

Permalink
pre-commit issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Zsailer committed Mar 14, 2024
1 parent d078e04 commit 7bbacaa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 5 additions & 5 deletions jupyter_events/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def register_event_schema(self, schema: SchemaType) -> None:
"""
event_schema = self.schemas.register(schema) # type:ignore[arg-type]
key = event_schema.id
# It's possible that listeners and modifiers have been added for this
# It's possible that listeners and modifiers have been added for this
# schema before the schema is registered.
if key not in self._modifiers:
self._modifiers[key] = set()
Expand Down Expand Up @@ -209,7 +209,7 @@ def add_modifier(
# If the schema ID and version is given, only add
# this modifier to that schema
if schema_id:
# If the schema hasn't been added yet,
# If the schema hasn't been added yet,
# start a placeholder set.
modifiers = self._modifiers.get(schema_id, set())
modifiers.add(modifier)
Expand Down Expand Up @@ -272,15 +272,15 @@ def add_listener(
# this modifier to that schema
if schema_id:
if modified:
# If the schema hasn't been added yet,
# If the schema hasn't been added yet,
# start a placeholder set.
listeners = self._modified_listeners.get(schema_id, set())
listeners.add(listener)
self._modified_listeners[schema_id] = listeners
self._modified_listeners[schema_id] = listeners
return
listeners = self._unmodified_listeners.get(schema_id, set())
listeners.add(listener)
self._unmodified_listeners[schema_id] = listeners
self._unmodified_listeners[schema_id] = listeners
return
for id_ in self.schemas.schema_ids:
if schema_id is None or id_ == schema_id:
Expand Down
8 changes: 6 additions & 2 deletions tests/test_listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ async def my_listener(logger: EventLogger, schema_id: str, data: dict) -> None:

@pytest.mark.parametrize(
# Make sure no schemas are added at the start of this test.
"jp_event_schemas", ([],)
"jp_event_schemas",
[
# Empty events list.
[]
],
)
async def test_listener_added_before_schemas_passes(jp_event_logger, schema):
# Ensure there are no schemas listed.
Expand All @@ -164,7 +168,7 @@ async def my_listener(logger: EventLogger, schema_id: str, data: dict) -> None:
assert not listener_was_called

# Now register the event and emit.
jp_event_logger.register_event_schema(schema)
jp_event_logger.register_event_schema(schema)

# Try emitting the event again and ensure the listener saw it.
jp_event_logger.emit(schema_id=schema.id, data={"prop": "hello, world"})
Expand Down

0 comments on commit 7bbacaa

Please sign in to comment.