|
1 | 1 | import threading
|
2 |
| -from _typeshed import StrPath |
| 2 | +from _typeshed import StrPath, SupportsWrite |
3 | 3 | from time import struct_time
|
4 | 4 | from types import FrameType, TracebackType
|
5 |
| -from typing import IO, Any, Callable, Dict, List, Mapping, MutableMapping, Optional, Sequence, Text, Tuple, Union, overload |
| 5 | +from typing import ( |
| 6 | + IO, |
| 7 | + Any, |
| 8 | + Callable, |
| 9 | + Dict, |
| 10 | + Generic, |
| 11 | + List, |
| 12 | + Mapping, |
| 13 | + MutableMapping, |
| 14 | + Optional, |
| 15 | + Sequence, |
| 16 | + Text, |
| 17 | + Tuple, |
| 18 | + TypeVar, |
| 19 | + Union, |
| 20 | + overload, |
| 21 | +) |
6 | 22 |
|
7 | 23 | _SysExcInfoType = Union[Tuple[type, BaseException, Optional[TracebackType]], Tuple[None, None, None]]
|
8 | 24 | _ExcInfoType = Union[None, bool, _SysExcInfoType]
|
@@ -159,10 +175,12 @@ class LogRecord:
|
159 | 175 | ) -> None: ...
|
160 | 176 | def getMessage(self) -> str: ...
|
161 | 177 |
|
162 |
| -class LoggerAdapter: |
163 |
| - logger: Logger |
| 178 | +_L = TypeVar("_L", Logger, LoggerAdapter[Logger], LoggerAdapter[Any]) |
| 179 | + |
| 180 | +class LoggerAdapter(Generic[_L]): |
| 181 | + logger: _L |
164 | 182 | extra: Mapping[str, Any]
|
165 |
| - def __init__(self, logger: Logger, extra: Mapping[str, Any]) -> None: ... |
| 183 | + def __init__(self, logger: _L, extra: Mapping[str, Any]) -> None: ... |
166 | 184 | def process(self, msg: Any, kwargs: MutableMapping[str, Any]) -> Tuple[Any, MutableMapping[str, Any]]: ...
|
167 | 185 | def debug(
|
168 | 186 | self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any
|
@@ -227,9 +245,14 @@ def shutdown(handlerList: Sequence[Any] = ...) -> None: ... # handlerList is un
|
227 | 245 | def setLoggerClass(klass: type) -> None: ...
|
228 | 246 | def captureWarnings(capture: bool) -> None: ...
|
229 | 247 |
|
230 |
| -class StreamHandler(Handler): |
231 |
| - stream: IO[str] # undocumented |
232 |
| - def __init__(self, stream: IO[str] | None = ...) -> None: ... |
| 248 | +_StreamT = TypeVar("_StreamT", bound=SupportsWrite[str]) |
| 249 | + |
| 250 | +class StreamHandler(Handler, Generic[_StreamT]): |
| 251 | + stream: _StreamT # undocumented |
| 252 | + @overload |
| 253 | + def __init__(self: StreamHandler[IO[str]], stream: None = ...) -> None: ... |
| 254 | + @overload |
| 255 | + def __init__(self: StreamHandler[_StreamT], stream: _StreamT) -> None: ... |
233 | 256 |
|
234 | 257 | class FileHandler(StreamHandler):
|
235 | 258 | baseFilename: str # undocumented
|
|
0 commit comments