Repository: litestar-org/litestar

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


Discussion:
I agree. Do you want to submit a PR?

Resolving patch:
diff --git a/starlite/types/__init__.py b/starlite/types/__init__.py
--- a/starlite/types/__init__.py
+++ b/starlite/types/__init__.py
@@ -83,6 +83,7 @@
     RouteHandlerType,
 )
 from .protocols import DataclassProtocol, Logger
+from .serialization import StarliteEncodableType
 
 __all__ = (
     "ASGIApp",
@@ -153,6 +154,7 @@
     "Scopes",
     "Send",
     "Serializer",
+    "StarliteEncodableType",
     "SyncOrAsyncUnion",
     "TypeEncodersMap",
     "TypedDictClass",
diff --git a/starlite/types/serialization.py b/starlite/types/serialization.py
new file mode 100644
--- /dev/null
+++ b/starlite/types/serialization.py
@@ -0,0 +1,54 @@
+from __future__ import annotations
+
+from typing import TYPE_CHECKING
+
+if TYPE_CHECKING:
+    from collections import deque
+    from collections.abc import Collection
+    from datetime import date, datetime, time
+    from decimal import Decimal
+    from enum import Enum, IntEnum
+    from ipaddress import (
+        IPv4Address,
+        IPv4Interface,
+        IPv4Network,
+        IPv6Address,
+        IPv6Interface,
+        IPv6Network,
+    )
+    from pathlib import Path, PurePath
+    from re import Pattern
+    from uuid import UUID
+
+    from msgspec import Raw, Struct
+    from msgspec.msgpack import Ext
+    from pydantic import (
+        BaseModel,
+        ByteSize,
+        ConstrainedBytes,
+        ConstrainedDate,
+        NameEmail,
+        SecretField,
+        StrictBool,
+    )
+    from pydantic.color import Color
+    from typing_extensions import TypeAlias
+
+    from starlite.types import DataclassProtocol
+
+__all__ = ("StarliteEncodableType",)
+
+EncodableBuiltinType: TypeAlias = "None | bool | int | float | str | bytes | bytearray"
+EncodableBuiltinCollectionType: TypeAlias = "list | tuple | set | frozenset | dict | Collection"
+EncodableStdLibType: TypeAlias = (
+    "date | datetime | deque | time | UUID | Decimal | Enum | IntEnum | DataclassProtocol | Path | PurePath | Pattern"
+)
+EncodableStdLibIPType: TypeAlias = (
+    "IPv4Address | IPv4Interface | IPv4Network | IPv6Address | IPv6Interface | IPv6Network"
+)
+EncodableMsgSpecType: TypeAlias = "Ext | Raw | Struct"
+EncodablePydanticType: TypeAlias = (
+    "BaseModel | ByteSize | ConstrainedBytes | ConstrainedDate | NameEmail | SecretField | StrictBool | Color"
+)
+
+StarliteEncodableType: TypeAlias = "EncodableBuiltinType | EncodableBuiltinCollectionType | EncodableStdLibType | EncodableStdLibIPType | EncodableMsgSpecType | EncodablePydanticType"


Test patch: