Skip to content

Commit

Permalink
Fix taskfile for simple projects (#430)
Browse files Browse the repository at this point in the history
* Reorganise some code and clear unused vars
* Fix taskfile
  • Loading branch information
tarsil authored Nov 10, 2024
1 parent 1eb4eb8 commit 5df293a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ tasks:

run:
desc: Starts {{ project_name }} in development mode
env:
ESMERALD_SETTINGS_MODULE: {{ project_name }}.configs.development.settings.DevelopmentAppSettings
cmds:
- esmerald runserver

Expand Down
12 changes: 6 additions & 6 deletions esmerald/routing/_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_base_annotations(base_annotation: Any) -> Dict[str, Any]:
Returns the annotations of the base class.
Args:
base (Any): The base class.
base_annotation (Any): The base class.
Returns:
Dict[str, Any]: The annotations of the base class.
Expand Down Expand Up @@ -195,17 +195,17 @@ def get_data_field(handler: Union["HTTPHandler", "WebhookHandler", Any]) -> Any:
default to the normal Esmerald processing, otherwise it will use the complex approach of
designing the OpenAPI body.
"""
# If there are no body fields, we simply return the original
# default Esmerald body parsing
if not handler.body_encoder_fields:
return get_original_data_field(handler)

is_data_or_payload = (
DATA
if DATA in handler.signature_model.model_fields
else (PAYLOAD if PAYLOAD in handler.signature_model.model_fields else None)
)

# If there are no body fields, we simply return the original
# default Esmerald body parsing
if not handler.body_encoder_fields:
return get_original_data_field(handler)

if len(handler.body_encoder_fields) < 2 and is_data_or_payload is not None:
return get_original_data_field(handler)
return get_complex_data_field(handler, fields=handler.body_encoder_fields)
Expand Down
1 change: 0 additions & 1 deletion esmerald/routing/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ async def _get_response_data(
Any: The response data generated by processing the request.
"""
signature_model = get_signature(route)
is_data_or_payload: str = None

if parameter_model.has_kwargs:
kwargs: Dict[str, Any] = parameter_model.to_kwargs(connection=request, handler=route)
Expand Down
1 change: 0 additions & 1 deletion esmerald/transformers/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from esmerald.types import Dependencies # pragma: no cover
from esmerald.websockets import WebSocket # pragma: no cover


MEDIA_TYPES = [EncodingType.MULTI_PART, EncodingType.URL_ENCODED]
MappingUnion = Mapping[Union[int, str], Any]

Expand Down

0 comments on commit 5df293a

Please sign in to comment.