Repository: litestar-org/litestar

Issue:
Bug: FieldMeta unexpected keyword argument 'constant'
### Description

After going from `polyfactory==2.0.0alpha1` => `2.0.0` I end up with `FieldMeta.__init__() got an unexpected keyword argument 'constant'`

Looks like the example generation for the openapi docs is broken because the `constant` boolean field is removed from 2.0.0

https://github.com/litestar-org/polyfactory/blob/v2.0.0/polyfactory/field_meta.py#L39-L48 (2.0.0)

vs

https://github.com/litestar-org/polyfactory/blob/v2.0.0alpha1/polyfactory/field_meta.py#L12-L21 (2.0.0a1)

And is set by https://github.com/litestar-org/litestar/blob/v2.0.0alpha4/litestar/_openapi/schema_generation/examples.py#L44 (2.0.0a4)

Running on docker `python:3.11-alpine`

### URL to code causing the issue

_No response_

### MCVE

```python
class TestController(Controller):
  path = "/test"

  @post(
    path="/route",
    summary="Test Route",
    tags=["Test"],
    responses={503: ResponseSpec(data_container=ServiceUnavailableModel, description="Device or service unavailable")},
  )
  async def test_route(self, data: SomeDataModel) -> SomeResponseModel:
    return {"test": data}
```

The `responses=` line causes this error. 


### Steps to reproduce

_No response_

### Screenshots

_No response_

### Logs

```bash
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/litestar/middleware/exceptions/middleware.py", line 149, in __call__
  await self.app(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/litestar/routes/http.py", line 77, in handle
  response = await self._get_response_for_request(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/routes/http.py", line 129, in _get_response_for_request
  response = await self._call_handler_function(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/routes/http.py", line 158, in _call_handler_function
  response_data, cleanup_group = await self._get_response_data(
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/routes/http.py", line 210, in _get_response_data
  data = route_handler.fn.value(**parsed_kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/openapi/controller.py", line 221, in root
  return Response(content=render_method(request), media_type=MediaType.HTML)
                          ^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/openapi/controller.py", line 397, in render_redoc
  schema = self.get_schema_from_request(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/openapi/controller.py", line 105, in get_schema_from_request
  return request.app.openapi_schema
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/app.py", line 510, in openapi_schema
  self.update_openapi_schema()
File "/usr/local/lib/python3.11/site-packages/litestar/app.py", line 825, in update_openapi_schema
  path_item, created_operation_ids = create_path_item(
                                     ^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/path_item.py", line 125, in create_path_item
  responses=create_responses(
            ^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/responses.py", line 259, in create_responses
  for status_code, response in create_additional_responses(
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/responses.py", line 226, in create_additional_responses
  schema = create_schema(
           ^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/schema_generation/schema.py", line 724, in create_schema
  result = create_schema_for_pydantic_model(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/schema_generation/schema.py", line 541, in create_schema_for_pydantic_model
  properties={
             ^
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/schema_generation/schema.py", line 542, in <dictcomp>
  (f.alias or f.name): create_schema(
                       ^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/schema_generation/schema.py", line 769, in create_schema
  return _process_schema_result(field=field, schema=result, generate_examples=generate_examples, schemas=schemas)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/schema_generation/schema.py", line 680, in _process_schema_result
  schema.examples = create_examples_for_field(field=field)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/schema_generation/examples.py", line 60, in create_examples_for_field
  field_meta = _create_field_meta(field)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/schema_generation/examples.py", line 41, in _create_field_meta
  return FieldMeta(
         ^^^^^^^^^^
TypeError: FieldMeta.__init__() got an unexpected keyword argument 'constant'
```


### Litestar Version

Litestar 2.0.0a4
polyfactory 2.0.0alpha1 (no error)
polyfactory 2.0.0 (error)

### Platform

- [ ] Linux
- [ ] Mac
- [ ] Windows
- [X] Other (Please specify in the description above)
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:
Can you provide an example that reproduces this?
Can be reproduced by forcing `polyfactory==2.0.0` and running `pytest tests/openapi`
I agree. Do you want to submit a PR?

Resolving patch:
diff --git a/litestar/_openapi/schema_generation/examples.py b/litestar/_openapi/schema_generation/examples.py
--- a/litestar/_openapi/schema_generation/examples.py
+++ b/litestar/_openapi/schema_generation/examples.py
@@ -41,7 +41,7 @@ def _create_field_meta(field: "SignatureField") -> FieldMeta:
     return FieldMeta(
         name=field.name,
         annotation=field.field_type,
-        constant=field.is_const,
+        constraints={"constant": field.is_const},
         default=field.default_value if field.default_value is not Empty else Null,
         children=[_create_field_meta(child) for child in field.children] if field.children else None,
     )


Test patch:
diff --git a/tests/openapi/test_parameters.py b/tests/openapi/test_parameters.py
--- a/tests/openapi/test_parameters.py
+++ b/tests/openapi/test_parameters.py
@@ -115,7 +115,7 @@ def test_create_parameters() -> None:
             {
                 "type": "string",
                 "enum": ["M", "F", "O", "A"],
-                "examples": [{"description": "Example  value", "value": "A"}],
+                "examples": [{"description": "Example  value", "value": "M"}],
             },
         ],
         "examples": [{"value": "M"}, {"value": ["M", "O"]}],
diff --git a/tests/openapi/test_responses.py b/tests/openapi/test_responses.py
--- a/tests/openapi/test_responses.py
+++ b/tests/openapi/test_responses.py
@@ -322,7 +322,6 @@ def handler() -> Person:
     schema = schemas[reference.ref.split("/")[-1]]
     assert isinstance(schema, Schema)
     assert schema.title == "AuthenticationError"
-    assert schema.examples
 
     second_response = next(responses)
     assert second_response[0] == "500"