mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 13:34:58 +08:00
logging: Add a _FilterProtocol type to Filterer.addFilter() filter argument. (#11018)
This commit is contained in:
@@ -7,7 +7,7 @@ from re import Pattern
|
||||
from string import Template
|
||||
from time import struct_time
|
||||
from types import FrameType, TracebackType
|
||||
from typing import Any, ClassVar, Generic, TextIO, TypeVar, overload
|
||||
from typing import Any, ClassVar, Generic, Protocol, TextIO, TypeVar, overload
|
||||
from typing_extensions import Literal, Self, TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
@@ -66,10 +66,20 @@ if sys.version_info >= (3, 12):
|
||||
_SysExcInfoType: TypeAlias = tuple[type[BaseException], BaseException, TracebackType | None] | tuple[None, None, None]
|
||||
_ExcInfoType: TypeAlias = None | bool | _SysExcInfoType | BaseException
|
||||
_ArgsType: TypeAlias = tuple[object, ...] | Mapping[str, object]
|
||||
_FilterType: TypeAlias = Filter | Callable[[LogRecord], bool]
|
||||
_Level: TypeAlias = int | str
|
||||
_FormatStyle: TypeAlias = Literal["%", "{", "$"]
|
||||
|
||||
if sys.version_info >= (3, 12):
|
||||
class _SupportsFilter(Protocol):
|
||||
def filter(self, __record: LogRecord) -> bool | LogRecord: ...
|
||||
|
||||
_FilterType: TypeAlias = Filter | Callable[[LogRecord], bool | LogRecord] | _SupportsFilter
|
||||
else:
|
||||
class _SupportsFilter(Protocol):
|
||||
def filter(self, __record: LogRecord) -> bool: ...
|
||||
|
||||
_FilterType: TypeAlias = Filter | Callable[[LogRecord], bool] | _SupportsFilter
|
||||
|
||||
raiseExceptions: bool
|
||||
logThreads: bool
|
||||
logMultiprocessing: bool
|
||||
|
||||
Reference in New Issue
Block a user