1
1
## Stubs for logging (Python 3.4)
2
2
3
3
from typing import (
4
- Any , Callable , Iterable , Mapping , MutableMapping , Optional , IO , Tuple ,
5
- Text , Union ,
6
- overload ,
4
+ Any , Callable , Dict , Iterable , Mapping , MutableMapping , Optional , IO ,
5
+ Tuple , Text , Union , overload ,
7
6
)
7
+ from string import Template
8
+ from time import struct_time
8
9
from types import TracebackType
9
10
import sys
10
11
@@ -26,7 +27,6 @@ class Logger:
26
27
handlers = ... # type: List[Handler]
27
28
disabled = ... # type: int
28
29
def setLevel (self , lvl : Union [int , str ]) -> None : ...
29
- def isEnabledFor (self , lvl : int ) -> Union [int , bool ]: ...
30
30
def getEffectiveLevel (self ) -> int : ...
31
31
def getChild (self , suffix : str ) -> 'Logger' : ...
32
32
if sys .version_info > (3 ,):
@@ -54,6 +54,7 @@ class Logger:
54
54
def exception (self , msg : Text , * args : Any , exc_info : _ExcInfoType = ...,
55
55
stack_info : bool = ..., extra : Dict [str , Any ] = ...,
56
56
** kwargs : Any ) -> None : ...
57
+ def isEnabledFor (self , lvl : int ) -> bool : ...
57
58
else :
58
59
def debug (self ,
59
60
msg : Text , * args : Any , exc_info : _ExcInfoType = ...,
@@ -79,6 +80,7 @@ class Logger:
79
80
def exception (self ,
80
81
msg : Text , * args : Any , exc_info : _ExcInfoType = ...,
81
82
extra : Dict [str , Any ] = ..., ** kwargs : Any ) -> None : ...
83
+ def isEnabledFor (self , lvl : int ) -> Union [int , bool ]: ...
82
84
def addFilter (self , filt : _FilterType ) -> None : ...
83
85
def removeFilter (self , filt : _FilterType ) -> None : ...
84
86
def filter (self , record : 'LogRecord' ) -> bool : ...
@@ -135,6 +137,14 @@ class Handler:
135
137
136
138
137
139
class Formatter :
140
+ converter = ... # type: Callable[[Optional[float]], struct_time]
141
+ _fmt = ... # type: Optional[str]
142
+ datefmt = ... # type: Optional[str]
143
+ if sys .version_info >= (3 ,):
144
+ _style = ... # type: PercentStyle
145
+ default_time_format = ... # type: str
146
+ default_msec_format = ... # type: str
147
+
138
148
if sys .version_info >= (3 ,):
139
149
def __init__ (self , fmt : Optional [str ] = ...,
140
150
datefmt : Optional [str ] = ...,
@@ -143,6 +153,7 @@ class Formatter:
143
153
def __init__ (self ,
144
154
fmt : Optional [str ] = ...,
145
155
datefmt : Optional [str ] = ...) -> None : ...
156
+
146
157
def format (self , record : LogRecord ) -> str : ...
147
158
def formatTime (self , record : LogRecord , datefmt : str = ...) -> str : ...
148
159
def formatException (self , exc_info : _SysExcInfoType ) -> str : ...
@@ -240,11 +251,13 @@ class LoggerAdapter:
240
251
def log (self ,
241
252
lvl : int , msg : Text , * args : Any , exc_info : _ExcInfoType = ...,
242
253
extra : Dict [str , Any ] = ..., ** kwargs : Any ) -> None : ...
243
- def isEnabledFor (self , lvl : int ) -> Union [int , bool ]: ...
244
254
if sys .version_info >= (3 ,):
255
+ def isEnabledFor (self , lvl : int ) -> bool : ...
245
256
def getEffectiveLevel (self ) -> int : ...
246
257
def setLevel (self , lvl : Union [int , str ]) -> None : ...
247
258
def hasHandlers (self ) -> bool : ...
259
+ else :
260
+ def isEnabledFor (self , lvl : int ) -> Union [int , bool ]: ...
248
261
249
262
250
263
if sys .version_info >= (3 ,):
@@ -353,3 +366,24 @@ class RootLogger(Logger):
353
366
pass
354
367
355
368
root = ... # type: RootLogger
369
+
370
+
371
+ if sys .version_info >= (3 ,):
372
+ class PercentStyle (object ):
373
+ default_format = ... # type: str
374
+ asctime_format = ... # type: str
375
+ asctime_search = ... # type: str
376
+ _fmt = ... # type: str
377
+
378
+ def __init__ (self , fmt ) -> None : ...
379
+ def usesTime (self ) -> bool : ...
380
+ def format (self , record : Any ) -> str : ...
381
+
382
+ class StrFormatStyle (PercentStyle ):
383
+ ...
384
+
385
+ class StringTemplateStyle (PercentStyle ):
386
+ _tpl = ... # type: Template
387
+
388
+ BASIC_FORMAT = ... # type: str
389
+ _STYLES = ... # type: Dict[str, Tuple[PercentStyle, str]]
0 commit comments