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: `litestar/contrib/sqlalchemy/types.py`
  Content:
  ```
  1 from __future__ import annotations
  2 
  3 import uuid
  4 from base64 import b64decode
  5 from typing import TYPE_CHECKING, Any, cast
  6 
  7 from sqlalchemy.dialects.oracle import BLOB as ORA_BLOB
  8 from sqlalchemy.dialects.oracle import RAW as ORA_RAW
  9 from sqlalchemy.dialects.postgresql import JSONB as PG_JSONB
  10 from sqlalchemy.dialects.postgresql import UUID as PG_UUID
  11 from sqlalchemy.types import BINARY, CHAR, BigInteger, Integer, TypeDecorator
  12 from sqlalchemy.types import JSON as _JSON
  13 
  14 if TYPE_CHECKING:
  15     from sqlalchemy.engine import Dialect
  16 
  17 BigIntIdentity = BigInteger().with_variant(Integer, "sqlite")
  18 
  19 
  20 class GUID(TypeDecorator):
  21     """Platform-independent GUID type.
  22 
  23     Uses PostgreSQL's UUID type, Oracle's RAW(16) type, otherwise uses
  24     BINARY(16) or CHAR(32), storing as stringified hex values.
  25 
  26     Will accept stringified UUIDs as a hexstring or an actual UUID
  27 
  28     """
  29 
  30     impl = BINARY(16)
  31     cache_ok = True
  32 
  33     @property
  34     def python_type(self) -> type[uuid.UUID]:
  35         return uuid.UUID
  36 
  37     def __init__(self, *args: Any, binary: bool = True, **kwargs: Any) -> None:
  38         self.binary = binary
  39 
  40     def load_dialect_impl(self, dialect: Dialect) -> Any:
  41         if dialect.name in {"postgresql", "duckdb"}:
  42             return dialect.type_descriptor(PG_UUID())
  43         if dialect.name == "oracle":
  44             return dialect.type_descriptor(ORA_RAW(16))
  45         if self.binary:
  46             return dialect.type_descriptor(BINARY(16))
  47         return dialect.type_descriptor(CHAR(32))
  48 
  49     def process_bind_param(self, value: bytes | str | uuid.UUID | None, dialect: Dialect) -> bytes | str | None:
  50         if value is None:
  51             return value
  52         if dialect.name in {"postgresql", "duckdb"}:
  53             return str(value)
  54         value = self.to_uuid(value)
  55         if value is None:
  56             return value
  57         if dialect.name in {"oracle", "spanner+spanner"}:
  58             return value.bytes
  59         return value.bytes if self.binary else value.hex
  60 
  61     def process_result_value(self, value: bytes | str | uuid.UUID | None, dialect: Dialect) -> uuid.UUID | None:
  62         if value is None:
  63             return value
  64         if isinstance(value, uuid.UUID):
  65             return value
  66         if dialect.name == "spanner+spanner":
  67             return uuid.UUID(bytes=b64decode(value))
  68         if self.binary:
  69             return uuid.UUID(bytes=cast("bytes", value))
  70         return uuid.UUID(hex=cast("str", value))
  71 
  72     @staticmethod
  73     def to_uuid(value: Any) -> uuid.UUID | None:
  74         if isinstance(value, uuid.UUID) or value is None:
  75             return value
  76         try:
  77             value = uuid.UUID(hex=value)
  78         except (TypeError, ValueError):
  79             value = uuid.UUID(bytes=value)
  80         return cast("uuid.UUID | None", value)
  81 
  82 
  83 class JSON(TypeDecorator):
  84     """Platform-independent JSON type.
  85 
  86     Uses JSONB type for postgres, BLOB for Oracle, otherwise uses the generic JSON data type.
  87 
  88     JSON = _JSON().with_variant(PG_JSONB, "postgresql").with_variant(ORA_BLOB, "oracle")
  89 
  90     """
  91 
  92     impl = _JSON
  93     cache_ok = True
  94 
  95     @property
  96     def python_type(self) -> type[dict]:
  97         return dict
  98 
  99     def __init__(self, *args: Any, **kwargs: Any) -> None:
  100         """Initialize JSON type"""
  101 
  102     def load_dialect_impl(self, dialect: Dialect) -> Any:
  103         if dialect.name == "postgresql":
  104             return dialect.type_descriptor(PG_JSONB())  # type: ignore
  105         if dialect.name == "oracle":
  106             return dialect.type_descriptor(ORA_BLOB())
  107         return dialect.type_descriptor(_JSON())
  108
  ```
  --- 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/litestar/contrib/sqlalchemy/types.py b/litestar/contrib/sqlalchemy/types.py
  --- a/litestar/contrib/sqlalchemy/types.py
  +++ b/litestar/contrib/sqlalchemy/types.py
  @@ -4,11 +4,12 @@
   from base64 import b64decode
   from typing import TYPE_CHECKING, Any, cast
   
  +from sqlalchemy import text, util
   from sqlalchemy.dialects.oracle import BLOB as ORA_BLOB
   from sqlalchemy.dialects.oracle import RAW as ORA_RAW
   from sqlalchemy.dialects.postgresql import JSONB as PG_JSONB
   from sqlalchemy.dialects.postgresql import UUID as PG_UUID
  -from sqlalchemy.types import BINARY, CHAR, BigInteger, Integer, TypeDecorator
  +from sqlalchemy.types import BINARY, CHAR, BigInteger, Integer, SchemaType, TypeDecorator
   from sqlalchemy.types import JSON as _JSON
   
   if TYPE_CHECKING:
  @@ -80,7 +81,7 @@
           return cast("uuid.UUID | None", value)
   
   
  -class JSON(TypeDecorator):
  +class JSON(TypeDecorator, SchemaType):  # type: ignore
       """Platform-independent JSON type.
   
       Uses JSONB type for postgres, BLOB for Oracle, otherwise uses the generic JSON data type.
  @@ -98,6 +99,8 @@
   
       def __init__(self, *args: Any, **kwargs: Any) -> None:
           """Initialize JSON type"""
  +        self.name = kwargs.pop("name", None)
  +        self.oracle_strict = kwargs.pop("oracle_strict", True)
   
       def load_dialect_impl(self, dialect: Dialect) -> Any:
           if dialect.name == "postgresql":
  @@ -105,3 +108,31 @@
           if dialect.name == "oracle":
               return dialect.type_descriptor(ORA_BLOB())
           return dialect.type_descriptor(_JSON())
  +
  +    def _should_create_constraint(self, compiler: Any, **kw: Any) -> bool:
  +        return bool(compiler.dialect.name == "oracle")
  +
  +    def _variant_mapping_for_set_table(self, column: Any) -> dict | None:
  +        if column.type._variant_mapping:
  +            variant_mapping = dict(column.type._variant_mapping)
  +            variant_mapping["_default"] = column.type
  +        else:
  +            variant_mapping = None
  +        return variant_mapping
  +
  +    @util.preload_module("sqlalchemy.sql.schema")
  +    def _set_table(self, column: Any, table: Any) -> None:
  +        schema = util.preloaded.sql_schema
  +        variant_mapping = self._variant_mapping_for_set_table(column)
  +        constraint_options = "(strict)" if self.oracle_strict else ""
  +        sqltext = text(f"{column.name} is json {constraint_options}")
  +        e = schema.CheckConstraint(
  +            sqltext,
  +            name=f"{column.name}_is_json",
  +            _create_rule=util.portable_instancemethod(  # type: ignore[no-untyped-call]
  +                self._should_create_constraint,
  +                {"variant_mapping": variant_mapping},
  +            ),
  +            _type_bound=True,
  +        )
  +        table.append_constraint(e)
  
verification_info: {"golden_diff": "diff --git a/litestar/contrib/sqlalchemy/types.py b/litestar/contrib/sqlalchemy/types.py\n--- a/litestar/contrib/sqlalchemy/types.py\n+++ b/litestar/contrib/sqlalchemy/types.py\n@@ -4,11 +4,12 @@\n from base64 import b64decode\n from typing import TYPE_CHECKING, Any, cast\n \n+from sqlalchemy import text, util\n from sqlalchemy.dialects.oracle import BLOB as ORA_BLOB\n from sqlalchemy.dialects.oracle import RAW as ORA_RAW\n from sqlalchemy.dialects.postgresql import JSONB as PG_JSONB\n from sqlalchemy.dialects.postgresql import UUID as PG_UUID\n-from sqlalchemy.types import BINARY, CHAR, BigInteger, Integer, TypeDecorator\n+from sqlalchemy.types import BINARY, CHAR, BigInteger, Integer, SchemaType, TypeDecorator\n from sqlalchemy.types import JSON as _JSON\n \n if TYPE_CHECKING:\n@@ -80,7 +81,7 @@\n         return cast(\"uuid.UUID | None\", value)\n \n \n-class JSON(TypeDecorator):\n+class JSON(TypeDecorator, SchemaType):  # type: ignore\n     \"\"\"Platform-independent JSON type.\n \n     Uses JSONB type for postgres, BLOB for Oracle, otherwise uses the generic JSON data type.\n@@ -98,6 +99,8 @@\n \n     def __init__(self, *args: Any, **kwargs: Any) -> None:\n         \"\"\"Initialize JSON type\"\"\"\n+        self.name = kwargs.pop(\"name\", None)\n+        self.oracle_strict = kwargs.pop(\"oracle_strict\", True)\n \n     def load_dialect_impl(self, dialect: Dialect) -> Any:\n         if dialect.name == \"postgresql\":\n@@ -105,3 +108,31 @@\n         if dialect.name == \"oracle\":\n             return dialect.type_descriptor(ORA_BLOB())\n         return dialect.type_descriptor(_JSON())\n+\n+    def _should_create_constraint(self, compiler: Any, **kw: Any) -> bool:\n+        return bool(compiler.dialect.name == \"oracle\")\n+\n+    def _variant_mapping_for_set_table(self, column: Any) -> dict | None:\n+        if column.type._variant_mapping:\n+            variant_mapping = dict(column.type._variant_mapping)\n+            variant_mapping[\"_default\"] = column.type\n+        else:\n+            variant_mapping = None\n+        return variant_mapping\n+\n+    @util.preload_module(\"sqlalchemy.sql.schema\")\n+    def _set_table(self, column: Any, table: Any) -> None:\n+        schema = util.preloaded.sql_schema\n+        variant_mapping = self._variant_mapping_for_set_table(column)\n+        constraint_options = \"(strict)\" if self.oracle_strict else \"\"\n+        sqltext = text(f\"{column.name} is json {constraint_options}\")\n+        e = schema.CheckConstraint(\n+            sqltext,\n+            name=f\"{column.name}_is_json\",\n+            _create_rule=util.portable_instancemethod(  # type: ignore[no-untyped-call]\n+                self._should_create_constraint,\n+                {\"variant_mapping\": variant_mapping},\n+            ),\n+            _type_bound=True,\n+        )\n+        table.append_constraint(e)\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\nimport uuid\nfrom base64 import b64decode\nfrom typing import TYPE_CHECKING, Any, cast\n\nfrom sqlalchemy.dialects.oracle import BLOB as ORA_BLOB\nfrom sqlalchemy.dialects.oracle import RAW as ORA_RAW\nfrom sqlalchemy.dialects.postgresql import JSONB as PG_JSONB\nfrom sqlalchemy.dialects.postgresql import UUID as PG_UUID\nfrom sqlalchemy.types import BINARY, CHAR, BigInteger, Integer, TypeDecorator\nfrom sqlalchemy.types import JSON as _JSON\n\nif TYPE_CHECKING:\n    from sqlalchemy.engine import Dialect\n\nBigIntIdentity = BigInteger().with_variant(Integer, \"sqlite\")\n\n\nclass GUID(TypeDecorator):\n    \"\"\"Platform-independent GUID type.\n\n    Uses PostgreSQL's UUID type, Oracle's RAW(16) type, otherwise uses\n    BINARY(16) or CHAR(32), storing as stringified hex values.\n\n    Will accept stringified UUIDs as a hexstring or an actual UUID\n\n    \"\"\"\n\n    impl = BINARY(16)\n    cache_ok = True\n\n    @property\n    def python_type(self) -> type[uuid.UUID]:\n        return uuid.UUID\n\n    def __init__(self, *args: Any, binary: bool = True, **kwargs: Any) -> None:\n        self.binary = binary\n\n    def load_dialect_impl(self, dialect: Dialect) -> Any:\n        if dialect.name in {\"postgresql\", \"duckdb\"}:\n            return dialect.type_descriptor(PG_UUID())\n        if dialect.name == \"oracle\":\n            return dialect.type_descriptor(ORA_RAW(16))\n        if self.binary:\n            return dialect.type_descriptor(BINARY(16))\n        return dialect.type_descriptor(CHAR(32))\n\n    def process_bind_param(self, value: bytes | str | uuid.UUID | None, dialect: Dialect) -> bytes | str | None:\n        if value is None:\n            return value\n        if dialect.name in {\"postgresql\", \"duckdb\"}:\n            return str(value)\n        value = self.to_uuid(value)\n        if value is None:\n            return value\n        if dialect.name in {\"oracle\", \"spanner+spanner\"}:\n            return value.bytes\n        return value.bytes if self.binary else value.hex\n\n    def process_result_value(self, value: bytes | str | uuid.UUID | None, dialect: Dialect) -> uuid.UUID | None:\n        if value is None:\n            return value\n        if isinstance(value, uuid.UUID):\n            return value\n        if dialect.name == \"spanner+spanner\":\n            return uuid.UUID(bytes=b64decode(value))\n        if self.binary:\n            return uuid.UUID(bytes=cast(\"bytes\", value))\n        return uuid.UUID(hex=cast(\"str\", value))\n\n    @staticmethod\n    def to_uuid(value: Any) -> uuid.UUID | None:\n        if isinstance(value, uuid.UUID) or value is None:\n            return value\n        try:\n            value = uuid.UUID(hex=value)\n        except (TypeError, ValueError):\n            value = uuid.UUID(bytes=value)\n        return cast(\"uuid.UUID | None\", value)\n\n\nclass JSON(TypeDecorator):\n    \"\"\"Platform-independent JSON type.\n\n    Uses JSONB type for postgres, BLOB for Oracle, otherwise uses the generic JSON data type.\n\n    JSON = _JSON().with_variant(PG_JSONB, \"postgresql\").with_variant(ORA_BLOB, \"oracle\")\n\n    \"\"\"\n\n    impl = _JSON\n    cache_ok = True\n\n    @property\n    def python_type(self) -> type[dict]:\n        return dict\n\n    def __init__(self, *args: Any, **kwargs: Any) -> None:\n        \"\"\"Initialize JSON type\"\"\"\n\n    def load_dialect_impl(self, dialect: Dialect) -> Any:\n        if dialect.name == \"postgresql\":\n            return dialect.type_descriptor(PG_JSONB())  # type: ignore\n        if dialect.name == \"oracle\":\n            return dialect.type_descriptor(ORA_BLOB())\n        return dialect.type_descriptor(_JSON())\n", "path": "litestar/contrib/sqlalchemy/types.py"}], "after_files": [{"content": "from __future__ import annotations\n\nimport uuid\nfrom base64 import b64decode\nfrom typing import TYPE_CHECKING, Any, cast\n\nfrom sqlalchemy import text, util\nfrom sqlalchemy.dialects.oracle import BLOB as ORA_BLOB\nfrom sqlalchemy.dialects.oracle import RAW as ORA_RAW\nfrom sqlalchemy.dialects.postgresql import JSONB as PG_JSONB\nfrom sqlalchemy.dialects.postgresql import UUID as PG_UUID\nfrom sqlalchemy.types import BINARY, CHAR, BigInteger, Integer, SchemaType, TypeDecorator\nfrom sqlalchemy.types import JSON as _JSON\n\nif TYPE_CHECKING:\n    from sqlalchemy.engine import Dialect\n\nBigIntIdentity = BigInteger().with_variant(Integer, \"sqlite\")\n\n\nclass GUID(TypeDecorator):\n    \"\"\"Platform-independent GUID type.\n\n    Uses PostgreSQL's UUID type, Oracle's RAW(16) type, otherwise uses\n    BINARY(16) or CHAR(32), storing as stringified hex values.\n\n    Will accept stringified UUIDs as a hexstring or an actual UUID\n\n    \"\"\"\n\n    impl = BINARY(16)\n    cache_ok = True\n\n    @property\n    def python_type(self) -> type[uuid.UUID]:\n        return uuid.UUID\n\n    def __init__(self, *args: Any, binary: bool = True, **kwargs: Any) -> None:\n        self.binary = binary\n\n    def load_dialect_impl(self, dialect: Dialect) -> Any:\n        if dialect.name in {\"postgresql\", \"duckdb\"}:\n            return dialect.type_descriptor(PG_UUID())\n        if dialect.name == \"oracle\":\n            return dialect.type_descriptor(ORA_RAW(16))\n        if self.binary:\n            return dialect.type_descriptor(BINARY(16))\n        return dialect.type_descriptor(CHAR(32))\n\n    def process_bind_param(self, value: bytes | str | uuid.UUID | None, dialect: Dialect) -> bytes | str | None:\n        if value is None:\n            return value\n        if dialect.name in {\"postgresql\", \"duckdb\"}:\n            return str(value)\n        value = self.to_uuid(value)\n        if value is None:\n            return value\n        if dialect.name in {\"oracle\", \"spanner+spanner\"}:\n            return value.bytes\n        return value.bytes if self.binary else value.hex\n\n    def process_result_value(self, value: bytes | str | uuid.UUID | None, dialect: Dialect) -> uuid.UUID | None:\n        if value is None:\n            return value\n        if isinstance(value, uuid.UUID):\n            return value\n        if dialect.name == \"spanner+spanner\":\n            return uuid.UUID(bytes=b64decode(value))\n        if self.binary:\n            return uuid.UUID(bytes=cast(\"bytes\", value))\n        return uuid.UUID(hex=cast(\"str\", value))\n\n    @staticmethod\n    def to_uuid(value: Any) -> uuid.UUID | None:\n        if isinstance(value, uuid.UUID) or value is None:\n            return value\n        try:\n            value = uuid.UUID(hex=value)\n        except (TypeError, ValueError):\n            value = uuid.UUID(bytes=value)\n        return cast(\"uuid.UUID | None\", value)\n\n\nclass JSON(TypeDecorator, SchemaType):  # type: ignore\n    \"\"\"Platform-independent JSON type.\n\n    Uses JSONB type for postgres, BLOB for Oracle, otherwise uses the generic JSON data type.\n\n    JSON = _JSON().with_variant(PG_JSONB, \"postgresql\").with_variant(ORA_BLOB, \"oracle\")\n\n    \"\"\"\n\n    impl = _JSON\n    cache_ok = True\n\n    @property\n    def python_type(self) -> type[dict]:\n        return dict\n\n    def __init__(self, *args: Any, **kwargs: Any) -> None:\n        \"\"\"Initialize JSON type\"\"\"\n        self.name = kwargs.pop(\"name\", None)\n        self.oracle_strict = kwargs.pop(\"oracle_strict\", True)\n\n    def load_dialect_impl(self, dialect: Dialect) -> Any:\n        if dialect.name == \"postgresql\":\n            return dialect.type_descriptor(PG_JSONB())  # type: ignore\n        if dialect.name == \"oracle\":\n            return dialect.type_descriptor(ORA_BLOB())\n        return dialect.type_descriptor(_JSON())\n\n    def _should_create_constraint(self, compiler: Any, **kw: Any) -> bool:\n        return bool(compiler.dialect.name == \"oracle\")\n\n    def _variant_mapping_for_set_table(self, column: Any) -> dict | None:\n        if column.type._variant_mapping:\n            variant_mapping = dict(column.type._variant_mapping)\n            variant_mapping[\"_default\"] = column.type\n        else:\n            variant_mapping = None\n        return variant_mapping\n\n    @util.preload_module(\"sqlalchemy.sql.schema\")\n    def _set_table(self, column: Any, table: Any) -> None:\n        schema = util.preloaded.sql_schema\n        variant_mapping = self._variant_mapping_for_set_table(column)\n        constraint_options = \"(strict)\" if self.oracle_strict else \"\"\n        sqltext = text(f\"{column.name} is json {constraint_options}\")\n        e = schema.CheckConstraint(\n            sqltext,\n            name=f\"{column.name}_is_json\",\n            _create_rule=util.portable_instancemethod(  # type: ignore[no-untyped-call]\n                self._should_create_constraint,\n                {\"variant_mapping\": variant_mapping},\n            ),\n            _type_bound=True,\n        )\n        table.append_constraint(e)\n", "path": "litestar/contrib/sqlalchemy/types.py"}]}