From 5672f181d95bd7d6cbc406ed01d3850066577759 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 14 Mar 2024 18:49:31 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- jupyter_events/logger.py | 10 +++++----- tests/test_listeners.py | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/jupyter_events/logger.py b/jupyter_events/logger.py index 96a3bf4..63838e0 100644 --- a/jupyter_events/logger.py +++ b/jupyter_events/logger.py @@ -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() @@ -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) @@ -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: diff --git a/tests/test_listeners.py b/tests/test_listeners.py index 97035cd..f925dc5 100644 --- a/tests/test_listeners.py +++ b/tests/test_listeners.py @@ -142,7 +142,8 @@ 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", + ([],), ) async def test_listener_added_before_schemas_passes(jp_event_logger, schema): # Ensure there are no schemas listed. @@ -164,7 +165,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"})