prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  StaticFilesConfig and virtual directories
  I'm trying to write a ``FileSystemProtocol`` to load files from the package data using [importlib_resources](https://importlib-resources.readthedocs.io/en/latest/using.html#). But because ``directories`` is defined as ``DirectoryPath``, pydantic checks if the given directories exist in the local filesystem. 
  
  This is not generally true, especially in any kind of virtual filesystem (e.g. a zipped package). I think this condition should be relaxed to support virtual filesystems.
  
  https://github.com/starlite-api/starlite/blob/9bb6dcd57c10a591377cf8e3a537e9292566d5b9/starlite/config/static_files.py#L32
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `starlite/events/emitter.py`
  Content:
  ```
  1 from __future__ import annotations
  2 
  3 from abc import ABC, abstractmethod
  4 from asyncio import CancelledError, Queue, Task, create_task
  5 from collections import defaultdict
  6 from contextlib import suppress
  7 from typing import TYPE_CHECKING, Any, DefaultDict, Sequence
  8 
  9 import sniffio
  10 
  11 from starlite.exceptions import ImproperlyConfiguredException
  12 
  13 __all__ = ("BaseEventEmitterBackend", "SimpleEventEmitter")
  14 
  15 
  16 if TYPE_CHECKING:
  17     from starlite.events.listener import EventListener
  18 
  19 
  20 class BaseEventEmitterBackend(ABC):
  21     """Abstract class used to define event emitter backends."""
  22 
  23     __slots__ = ("listeners",)
  24 
  25     listeners: DefaultDict[str, set[EventListener]]
  26 
  27     def __init__(self, listeners: Sequence[EventListener]):
  28         """Create an event emitter instance.
  29 
  30         Args:
  31             listeners: A list of listeners.
  32         """
  33         self.listeners = defaultdict(set)
  34         for listener in listeners:
  35             for event_id in listener.event_ids:
  36                 self.listeners[event_id].add(listener)
  37 
  38     @abstractmethod
  39     def emit(self, event_id: str, *args: Any, **kwargs: Any) -> None:  # pragma: no cover
  40         """Emit an event to all attached listeners.
  41 
  42         Args:
  43             event_id: The ID of the event to emit, e.g 'my_event'.
  44             *args: args to pass to the listener(s).
  45             **kwargs: kwargs to pass to the listener(s)
  46 
  47         Returns:
  48             None
  49         """
  50         raise NotImplementedError("not implemented")
  51 
  52     @abstractmethod
  53     async def on_startup(self) -> None:  # pragma: no cover
  54         """Hook called on application startup, used to establish connection or perform other async operations.
  55 
  56         Returns:
  57             None
  58         """
  59         raise NotImplementedError("not implemented")
  60 
  61     @abstractmethod
  62     async def on_shutdown(self) -> None:  # pragma: no cover
  63         """Hook called on application shutdown, used to perform cleanup.
  64 
  65         Returns:
  66             None
  67         """
  68         raise NotImplementedError("not implemented")
  69 
  70 
  71 class SimpleEventEmitter(BaseEventEmitterBackend):
  72     """Event emitter the works only in the current process"""
  73 
  74     __slots__ = ("_queue", "_worker_task")
  75 
  76     _worker_task: Task | None
  77 
  78     def __init__(self, listeners: Sequence[EventListener]):
  79         """Create an event emitter instance.
  80 
  81         Args:
  82             listeners: A list of listeners.
  83         """
  84         super().__init__(listeners=listeners)
  85         self._queue: Queue | None = None
  86         self._worker_task = None
  87 
  88     async def _worker(self) -> None:
  89         """Worker that runs in a separate task and continuously pulls events from asyncio queue.
  90 
  91         Returns:
  92             None
  93         """
  94         while self._queue:
  95             fn, args, kwargs = await self._queue.get()
  96             await fn(*args, *kwargs)
  97             self._queue.task_done()
  98 
  99     async def on_startup(self) -> None:
  100         """Hook called on application startup, used to establish connection or perform other async operations.
  101 
  102         Returns:
  103             None
  104         """
  105         if sniffio.current_async_library() != "asyncio":
  106             return
  107 
  108         self._queue = Queue()
  109         self._worker_task = create_task(self._worker())
  110 
  111     async def on_shutdown(self) -> None:
  112         """Hook called on application shutdown, used to perform cleanup.
  113 
  114         Returns:
  115             None
  116         """
  117 
  118         if self._queue:
  119             await self._queue.join()
  120 
  121         if self._worker_task:
  122             self._worker_task.cancel()
  123             with suppress(CancelledError):
  124                 await self._worker_task
  125 
  126         self._worker_task = None
  127         self._queue = None
  128 
  129     def emit(self, event_id: str, *args: Any, **kwargs: Any) -> None:
  130         """Emit an event to all attached listeners.
  131 
  132         Args:
  133             event_id: The ID of the event to emit, e.g 'my_event'.
  134             *args: args to pass to the listener(s).
  135             **kwargs: kwargs to pass to the listener(s)
  136 
  137         Returns:
  138             None
  139         """
  140         if not (self._worker_task and self._queue):
  141             if sniffio.current_async_library() != "asyncio":
  142                 raise ImproperlyConfiguredException("{type(self).__name__} only supports 'asyncio' based event loops")
  143 
  144             raise ImproperlyConfiguredException("Worker not running")
  145 
  146         if listeners := self.listeners.get(event_id):
  147             for listener in listeners:
  148                 self._queue.put_nowait((listener.fn, args, kwargs))
  149             return
  150         raise ImproperlyConfiguredException(f"no event listeners are registered for event ID: {event_id}")
  151
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/starlite/events/emitter.py b/starlite/events/emitter.py
  --- a/starlite/events/emitter.py
  +++ b/starlite/events/emitter.py
  @@ -93,7 +93,7 @@
           """
           while self._queue:
               fn, args, kwargs = await self._queue.get()
  -            await fn(*args, *kwargs)
  +            await fn(*args, **kwargs)
               self._queue.task_done()
   
       async def on_startup(self) -> None:
  
verification_info: {"golden_diff": "diff --git a/starlite/events/emitter.py b/starlite/events/emitter.py\n--- a/starlite/events/emitter.py\n+++ b/starlite/events/emitter.py\n@@ -93,7 +93,7 @@\n         \"\"\"\n         while self._queue:\n             fn, args, kwargs = await self._queue.get()\n-            await fn(*args, *kwargs)\n+            await fn(*args, **kwargs)\n             self._queue.task_done()\n \n     async def on_startup(self) -> None:\n", "issue": "StaticFilesConfig and virtual directories\nI'm trying to write a ``FileSystemProtocol`` to load files from the package data using [importlib_resources](https://importlib-resources.readthedocs.io/en/latest/using.html#). But because ``directories`` is defined as ``DirectoryPath``, pydantic checks if the given directories exist in the local filesystem. \r\n\r\nThis is not generally true, especially in any kind of virtual filesystem (e.g. a zipped package). I think this condition should be relaxed to support virtual filesystems.\r\n\r\nhttps://github.com/starlite-api/starlite/blob/9bb6dcd57c10a591377cf8e3a537e9292566d5b9/starlite/config/static_files.py#L32\n", "before_files": [{"content": "from __future__ import annotations\n\nfrom abc import ABC, abstractmethod\nfrom asyncio import CancelledError, Queue, Task, create_task\nfrom collections import defaultdict\nfrom contextlib import suppress\nfrom typing import TYPE_CHECKING, Any, DefaultDict, Sequence\n\nimport sniffio\n\nfrom starlite.exceptions import ImproperlyConfiguredException\n\n__all__ = (\"BaseEventEmitterBackend\", \"SimpleEventEmitter\")\n\n\nif TYPE_CHECKING:\n    from starlite.events.listener import EventListener\n\n\nclass BaseEventEmitterBackend(ABC):\n    \"\"\"Abstract class used to define event emitter backends.\"\"\"\n\n    __slots__ = (\"listeners\",)\n\n    listeners: DefaultDict[str, set[EventListener]]\n\n    def __init__(self, listeners: Sequence[EventListener]):\n        \"\"\"Create an event emitter instance.\n\n        Args:\n            listeners: A list of listeners.\n        \"\"\"\n        self.listeners = defaultdict(set)\n        for listener in listeners:\n            for event_id in listener.event_ids:\n                self.listeners[event_id].add(listener)\n\n    @abstractmethod\n    def emit(self, event_id: str, *args: Any, **kwargs: Any) -> None:  # pragma: no cover\n        \"\"\"Emit an event to all attached listeners.\n\n        Args:\n            event_id: The ID of the event to emit, e.g 'my_event'.\n            *args: args to pass to the listener(s).\n            **kwargs: kwargs to pass to the listener(s)\n\n        Returns:\n            None\n        \"\"\"\n        raise NotImplementedError(\"not implemented\")\n\n    @abstractmethod\n    async def on_startup(self) -> None:  # pragma: no cover\n        \"\"\"Hook called on application startup, used to establish connection or perform other async operations.\n\n        Returns:\n            None\n        \"\"\"\n        raise NotImplementedError(\"not implemented\")\n\n    @abstractmethod\n    async def on_shutdown(self) -> None:  # pragma: no cover\n        \"\"\"Hook called on application shutdown, used to perform cleanup.\n\n        Returns:\n            None\n        \"\"\"\n        raise NotImplementedError(\"not implemented\")\n\n\nclass SimpleEventEmitter(BaseEventEmitterBackend):\n    \"\"\"Event emitter the works only in the current process\"\"\"\n\n    __slots__ = (\"_queue\", \"_worker_task\")\n\n    _worker_task: Task | None\n\n    def __init__(self, listeners: Sequence[EventListener]):\n        \"\"\"Create an event emitter instance.\n\n        Args:\n            listeners: A list of listeners.\n        \"\"\"\n        super().__init__(listeners=listeners)\n        self._queue: Queue | None = None\n        self._worker_task = None\n\n    async def _worker(self) -> None:\n        \"\"\"Worker that runs in a separate task and continuously pulls events from asyncio queue.\n\n        Returns:\n            None\n        \"\"\"\n        while self._queue:\n            fn, args, kwargs = await self._queue.get()\n            await fn(*args, *kwargs)\n            self._queue.task_done()\n\n    async def on_startup(self) -> None:\n        \"\"\"Hook called on application startup, used to establish connection or perform other async operations.\n\n        Returns:\n            None\n        \"\"\"\n        if sniffio.current_async_library() != \"asyncio\":\n            return\n\n        self._queue = Queue()\n        self._worker_task = create_task(self._worker())\n\n    async def on_shutdown(self) -> None:\n        \"\"\"Hook called on application shutdown, used to perform cleanup.\n\n        Returns:\n            None\n        \"\"\"\n\n        if self._queue:\n            await self._queue.join()\n\n        if self._worker_task:\n            self._worker_task.cancel()\n            with suppress(CancelledError):\n                await self._worker_task\n\n        self._worker_task = None\n        self._queue = None\n\n    def emit(self, event_id: str, *args: Any, **kwargs: Any) -> None:\n        \"\"\"Emit an event to all attached listeners.\n\n        Args:\n            event_id: The ID of the event to emit, e.g 'my_event'.\n            *args: args to pass to the listener(s).\n            **kwargs: kwargs to pass to the listener(s)\n\n        Returns:\n            None\n        \"\"\"\n        if not (self._worker_task and self._queue):\n            if sniffio.current_async_library() != \"asyncio\":\n                raise ImproperlyConfiguredException(\"{type(self).__name__} only supports 'asyncio' based event loops\")\n\n            raise ImproperlyConfiguredException(\"Worker not running\")\n\n        if listeners := self.listeners.get(event_id):\n            for listener in listeners:\n                self._queue.put_nowait((listener.fn, args, kwargs))\n            return\n        raise ImproperlyConfiguredException(f\"no event listeners are registered for event ID: {event_id}\")\n", "path": "starlite/events/emitter.py"}], "after_files": [{"content": "from __future__ import annotations\n\nfrom abc import ABC, abstractmethod\nfrom asyncio import CancelledError, Queue, Task, create_task\nfrom collections import defaultdict\nfrom contextlib import suppress\nfrom typing import TYPE_CHECKING, Any, DefaultDict, Sequence\n\nimport sniffio\n\nfrom starlite.exceptions import ImproperlyConfiguredException\n\n__all__ = (\"BaseEventEmitterBackend\", \"SimpleEventEmitter\")\n\n\nif TYPE_CHECKING:\n    from starlite.events.listener import EventListener\n\n\nclass BaseEventEmitterBackend(ABC):\n    \"\"\"Abstract class used to define event emitter backends.\"\"\"\n\n    __slots__ = (\"listeners\",)\n\n    listeners: DefaultDict[str, set[EventListener]]\n\n    def __init__(self, listeners: Sequence[EventListener]):\n        \"\"\"Create an event emitter instance.\n\n        Args:\n            listeners: A list of listeners.\n        \"\"\"\n        self.listeners = defaultdict(set)\n        for listener in listeners:\n            for event_id in listener.event_ids:\n                self.listeners[event_id].add(listener)\n\n    @abstractmethod\n    def emit(self, event_id: str, *args: Any, **kwargs: Any) -> None:  # pragma: no cover\n        \"\"\"Emit an event to all attached listeners.\n\n        Args:\n            event_id: The ID of the event to emit, e.g 'my_event'.\n            *args: args to pass to the listener(s).\n            **kwargs: kwargs to pass to the listener(s)\n\n        Returns:\n            None\n        \"\"\"\n        raise NotImplementedError(\"not implemented\")\n\n    @abstractmethod\n    async def on_startup(self) -> None:  # pragma: no cover\n        \"\"\"Hook called on application startup, used to establish connection or perform other async operations.\n\n        Returns:\n            None\n        \"\"\"\n        raise NotImplementedError(\"not implemented\")\n\n    @abstractmethod\n    async def on_shutdown(self) -> None:  # pragma: no cover\n        \"\"\"Hook called on application shutdown, used to perform cleanup.\n\n        Returns:\n            None\n        \"\"\"\n        raise NotImplementedError(\"not implemented\")\n\n\nclass SimpleEventEmitter(BaseEventEmitterBackend):\n    \"\"\"Event emitter the works only in the current process\"\"\"\n\n    __slots__ = (\"_queue\", \"_worker_task\")\n\n    _worker_task: Task | None\n\n    def __init__(self, listeners: Sequence[EventListener]):\n        \"\"\"Create an event emitter instance.\n\n        Args:\n            listeners: A list of listeners.\n        \"\"\"\n        super().__init__(listeners=listeners)\n        self._queue: Queue | None = None\n        self._worker_task = None\n\n    async def _worker(self) -> None:\n        \"\"\"Worker that runs in a separate task and continuously pulls events from asyncio queue.\n\n        Returns:\n            None\n        \"\"\"\n        while self._queue:\n            fn, args, kwargs = await self._queue.get()\n            await fn(*args, **kwargs)\n            self._queue.task_done()\n\n    async def on_startup(self) -> None:\n        \"\"\"Hook called on application startup, used to establish connection or perform other async operations.\n\n        Returns:\n            None\n        \"\"\"\n        if sniffio.current_async_library() != \"asyncio\":\n            return\n\n        self._queue = Queue()\n        self._worker_task = create_task(self._worker())\n\n    async def on_shutdown(self) -> None:\n        \"\"\"Hook called on application shutdown, used to perform cleanup.\n\n        Returns:\n            None\n        \"\"\"\n\n        if self._queue:\n            await self._queue.join()\n\n        if self._worker_task:\n            self._worker_task.cancel()\n            with suppress(CancelledError):\n                await self._worker_task\n\n        self._worker_task = None\n        self._queue = None\n\n    def emit(self, event_id: str, *args: Any, **kwargs: Any) -> None:\n        \"\"\"Emit an event to all attached listeners.\n\n        Args:\n            event_id: The ID of the event to emit, e.g 'my_event'.\n            *args: args to pass to the listener(s).\n            **kwargs: kwargs to pass to the listener(s)\n\n        Returns:\n            None\n        \"\"\"\n        if not (self._worker_task and self._queue):\n            if sniffio.current_async_library() != \"asyncio\":\n                raise ImproperlyConfiguredException(\"{type(self).__name__} only supports 'asyncio' based event loops\")\n\n            raise ImproperlyConfiguredException(\"Worker not running\")\n\n        if listeners := self.listeners.get(event_id):\n            for listener in listeners:\n                self._queue.put_nowait((listener.fn, args, kwargs))\n            return\n        raise ImproperlyConfiguredException(f\"no event listeners are registered for event ID: {event_id}\")\n", "path": "starlite/events/emitter.py"}]}