Skip to content

Conversation

@Snuffy2
Copy link
Contributor

@Snuffy2 Snuffy2 commented Nov 23, 2025

This pull request refactors the RequestTrackingMiddleware in app/middleware/request_tracking.py to improve type safety, update error logging, and clarify documentation. The main changes focus on using more precise type annotations, enhancing error logging, and cleaning up the request handling logic.

Type annotation improvements:

  • Updated the type annotation for the call_next parameter in the dispatch method to use Callable[[Request], Awaitable[Response]] for better type safety. [1] [2]
  • Added explicit type annotation for the response variable, clarifying its type as Response.

Error handling and logging enhancements:

  • Changed error logging from logger.error to logger.exception to automatically include stack traces for better debugging. Also removed the redundant exc_info=True argument.
  • Simplified error message formatting and removed direct exception string interpolation, focusing on duration and request details.

Documentation improvements:

  • Updated the docstring for the dispatch method to use a more standard format with section headers for arguments and return values.

@Snuffy2 Snuffy2 force-pushed the Linting/Formatting-of-middleware-folder branch from 253a633 to c99ec32 Compare November 30, 2025 02:26
@Snuffy2 Snuffy2 force-pushed the Linting/Formatting-of-middleware-folder branch from c99ec32 to ee9a615 Compare November 30, 2025 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant