Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
provinzkraut committed Sep 14, 2024
1 parent dfdd92a commit 8ed0132
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
6 changes: 1 addition & 5 deletions litestar/_openapi/datastructures.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import weakref
from collections import defaultdict
from typing import TYPE_CHECKING, Iterator, Sequence, _GenericAlias # type: ignore[attr-defined]

Expand Down Expand Up @@ -97,10 +96,7 @@ def __init__(self) -> None:
self._schema_key_map: dict[tuple[str, ...], RegisteredSchema] = {}
self._schema_reference_map: dict[int, RegisteredSchema] = {}
self._model_name_groups: defaultdict[str, list[RegisteredSchema]] = defaultdict(list)
# no need to hold onto transient FieldDefinitions here so we're using weakrefs
self._component_type_map: weakref.WeakValueDictionary[tuple[str, ...], FieldDefinition] = (
weakref.WeakValueDictionary()
)
self._component_type_map: dict[str, FieldDefinition] = {}

def get_schema_for_field_definition(self, field: FieldDefinition) -> Schema:
"""Get a registered schema by its key.
Expand Down
1 change: 0 additions & 1 deletion litestar/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ class FieldDefinition:
"raw",
"safe_generic_origin",
"type_wrappers",
"__weakref__",
)

raw: Any
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_openapi/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ class Data:
@post("/")
def handler(
data: Data,
) -> Annotated[Data, Parameter(component_key="not_data")]:
) -> Annotated[Data, Parameter(schema_component_key="not_data")]:
return Data()

@get("/")
def handler_2() -> Annotated[Data, Parameter(component_key="not_data")]:
def handler_2() -> Annotated[Data, Parameter(schema_component_key="not_data")]:
return Data()

app = Litestar([handler, handler_2])
Expand Down Expand Up @@ -142,11 +142,11 @@ class Data2:
@post("/")
def handler(
data: Data,
) -> Annotated[Data, Parameter(component_key="not_data")]:
) -> Annotated[Data, Parameter(schema_component_key="not_data")]:
return Data()

@get("/")
def handler_2() -> Annotated[Data2, Parameter(component_key="not_data")]:
def handler_2() -> Annotated[Data2, Parameter(schema_component_key="not_data")]:
return Data2()

with pytest.raises(ImproperlyConfiguredException, match="Schema component keys must be unique"):
Expand Down

0 comments on commit 8ed0132

Please sign in to comment.