Skip to content

Commit

Permalink
refactor(pydantic plugin): remove unused parameter (#2564)
Browse files Browse the repository at this point in the history
remove unused parameter

Signed-off-by: Janek Nouvertné <[email protected]>
  • Loading branch information
provinzkraut authored Oct 30, 2023
1 parent 46ea14b commit ec069e7
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions litestar/contrib/pydantic/pydantic_schema_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,22 +227,16 @@ def to_openapi_schema(self, field_definition: FieldDefinition, schema_creator: S
if schema_creator.prefer_alias != self.prefer_alias:
schema_creator.prefer_alias = True
if is_pydantic_model_class(field_definition.annotation):
return self.for_pydantic_model(
field_definition=field_definition, annotation=field_definition.annotation, schema_creator=schema_creator
)
return self.for_pydantic_model(field_definition=field_definition, schema_creator=schema_creator)
return PYDANTIC_TYPE_MAP[field_definition.annotation] # pragma: no cover

@classmethod
def for_pydantic_model(
cls,
field_definition: FieldDefinition,
annotation: type[pydantic_v1.BaseModel | pydantic_v2.BaseModel], # pyright: ignore
schema_creator: SchemaCreator,
cls, field_definition: FieldDefinition, schema_creator: SchemaCreator
) -> Schema: # pyright: ignore
"""Create a schema object for a given pydantic model class.
Args:
annotation: A pydantic model class.
field_definition: FieldDefinition instance.
schema_creator: An instance of the schema creator class
Expand All @@ -260,7 +254,7 @@ def for_pydantic_model(
example = model_config.get("example")
is_v2_model = True
else:
model_config = annotation.__config__ # type: ignore[union-attr, assignment]
model_config = annotation.__config__
model_field_info = unwrapped_annotation.__fields__
title = getattr(model_config, "title", None)
example = getattr(model_config, "example", None)
Expand Down

0 comments on commit ec069e7

Please sign in to comment.