Skip to content

Commit

Permalink
refactor: replace unnecessary use of default_factory with default (
Browse files Browse the repository at this point in the history
…#2923)

* refactor: fix misuse of default_factory from dataclass field

* refactor: set middleware_class as field like other fields

Co-authored-by: Boseong Choi <[email protected]>

---------

Co-authored-by: Boseong Choi <[email protected]>
Co-authored-by: Peter Schutt <[email protected]>
  • Loading branch information
3 people authored Dec 23, 2023
1 parent 91762e5 commit 02ca07d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions litestar/middleware/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class LoggingMiddlewareConfig:
response_log_message: str = field(default="HTTP Response")
"""Log message to prepend when logging a response."""
request_log_fields: Iterable[RequestExtractorField] = field(
default_factory=lambda: (
default=(
"path",
"method",
"content_type",
Expand All @@ -290,7 +290,7 @@ class LoggingMiddlewareConfig:
- To turn off logging of requests, use and empty iterable.
"""
response_log_fields: Iterable[ResponseExtractorField] = field(
default_factory=lambda: (
default=(
"status_code",
"cookies",
"headers",
Expand All @@ -305,7 +305,7 @@ class LoggingMiddlewareConfig:
Thus, re-arranging the log-message is as simple as changing the iterable.
- To turn off logging of responses, use and empty iterable.
"""
middleware_class: type[LoggingMiddleware] = field(default_factory=lambda: LoggingMiddleware)
middleware_class: type[LoggingMiddleware] = field(default=LoggingMiddleware)
"""Middleware class to use.
Should be a subclass of [litestar.middleware.LoggingMiddleware].
Expand Down

0 comments on commit 02ca07d

Please sign in to comment.