refactor: Add typing stubs for PyYAML and improve type hints in logging utilities and extensions
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Dict, Any, List, Optional
|
||||
from typing import Dict, Any, List, Optional, Type
|
||||
from starlette.requests import Request
|
||||
from starlette.responses import Response
|
||||
from .logging_utils import get_logger
|
||||
@@ -101,7 +101,7 @@ class MonitoringExtension(Extension):
|
||||
super().__init__(config)
|
||||
self.request_count = 0
|
||||
self.error_count = 0
|
||||
self.response_times = []
|
||||
self.response_times: list[float] = []
|
||||
self.enable_metrics = config.get("enable_metrics", True)
|
||||
|
||||
async def process_request(self, request: Request) -> Optional[Response]:
|
||||
@@ -138,16 +138,16 @@ class MonitoringExtension(Extension):
|
||||
|
||||
|
||||
class ExtensionManager:
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
self.extensions: List[Extension] = []
|
||||
self.extension_registry = {
|
||||
self.extension_registry: Dict[str, Type[Extension]] = {
|
||||
"routing": RoutingExtension,
|
||||
"security": SecurityExtension,
|
||||
"caching": CachingExtension,
|
||||
"monitoring": MonitoringExtension
|
||||
}
|
||||
|
||||
def register_extension_type(self, name: str, extension_class: type) -> None:
|
||||
def register_extension_type(self, name: str, extension_class: Type[Extension]) -> None:
|
||||
self.extension_registry[name] = extension_class
|
||||
|
||||
def load_extension(self, extension_type: str, config: Dict[str, Any]) -> None:
|
||||
|
||||
Reference in New Issue
Block a user