Skip to content

Commit

Permalink
chore(mypy): enable more mypy codes (#3817)
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn authored Oct 16, 2024
1 parent 236cfa3 commit a7cd193
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions litestar/middleware/logging.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any, Iterable
from typing import TYPE_CHECKING, Any, Collection, Iterable

from litestar.constants import (
HTTP_RESPONSE_BODY,
Expand Down Expand Up @@ -273,7 +273,7 @@ class LoggingMiddlewareConfig:
"""Log message to prepend when logging a request."""
response_log_message: str = field(default="HTTP Response")
"""Log message to prepend when logging a response."""
request_log_fields: Iterable[RequestExtractorField] = field(
request_log_fields: Collection[RequestExtractorField] = field(
default=(
"path",
"method",
Expand All @@ -292,7 +292,7 @@ class LoggingMiddlewareConfig:
Thus, re-arranging the log-message is as simple as changing the iterable.
- To turn off logging of requests, use and empty iterable.
"""
response_log_fields: Iterable[ResponseExtractorField] = field(
response_log_fields: Collection[ResponseExtractorField] = field(
default=(
"status_code",
"cookies",
Expand Down
2 changes: 1 addition & 1 deletion litestar/testing/websocket_test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def receive() -> WebSocketReceiveMessage:
async def send(message: WebSocketSendMessage) -> None:
if message["type"] == "websocket.accept":
headers = message.get("headers", [])
if headers:
if headers: # type: ignore[truthy-iterable]
headers_list = list(self.scope["headers"])
headers_list.extend(headers)
self.scope["headers"] = headers_list
Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,16 @@ xfail_strict = true
[tool.mypy]
packages = ["litestar", "tests"]
plugins = ["pydantic.mypy"]
enable_error_code = [
"truthy-iterable",
"unused-awaitable",
"ignore-without-code",
"redundant-self",
]
python_version = "3.8"

disallow_any_generics = false
disallow_untyped_decorators = true
enable_error_code = "ignore-without-code"
implicit_reexport = false
show_error_codes = true
strict = true
Expand All @@ -256,6 +261,7 @@ warn_return_any = true
warn_unreachable = true
warn_unused_configs = true
warn_unused_ignores = true
local_partial_types = true

[[tool.mypy.overrides]]
ignore_errors = true
Expand Down

0 comments on commit a7cd193

Please sign in to comment.