Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(mypy): enable more mypy codes #3817

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading