Coverage for src/lumen/core/context.py: 100%

4 statements  

« prev     ^ index     » next       coverage.py v7.16.0, created at 2026-08-31 18:46 +0000

1""" 

2This file manages request-scoped variables using contextvars. 

3It keeps track of the current authenticated claims and client IP address. 

4""" 

5 

6from contextvars import ContextVar 

7from typing import Any 

8 

9# Stores the JWT claims of the currently authenticated user (if any) 

10current_claims: ContextVar[dict[str, Any] | None] = ContextVar("current_claims", default=None) 

11 

12# Stores the IP address of the client making the request 

13current_client_ip: ContextVar[str | None] = ContextVar("current_client_ip", default=None)