Skip to content

Commit

Permalink
pythonic findWhere
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulhaq-e committed Aug 18, 2023
1 parent f7f3da2 commit 0cb1251
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions litestar/contrib/sqlalchemy/dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,7 @@ def get_sqlalchemy_dto_config_from_annotated_type(
Returns:
The type and config object extracted from the annotation.
"""
return next((item for item in field_definition.metadata if isinstance(item, SQLAlchemyDTOConfig)), None)
return configs[0]
return None
return next((item for item in field_definition.metadata if isinstance(item, SQLAlchemyDTOConfig)), None)


def _detect_defaults(elem: ElementType) -> tuple[Any, Any]:
Expand Down
4 changes: 1 addition & 3 deletions litestar/dto/base_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@ def get_dto_config_from_annotated_type(field_definition: FieldDefinition) -> DTO
Returns:
The type and config object extracted from the annotation.
"""
if configs := [item for item in field_definition.metadata if isinstance(item, DTOConfig)]:
return configs[0]
return None
return next((item for item in field_definition.metadata if isinstance(item, DTOConfig)), None)

@classmethod
def resolve_model_type(cls, field_definition: FieldDefinition) -> FieldDefinition:
Expand Down

0 comments on commit 0cb1251

Please sign in to comment.