Skip to content

Commit eed6015

Browse files
committed
Refactor to support Py 3.12+ for all logging filters.
1 parent 55e3710 commit eed6015

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

stdlib/logging/__init__.pyi

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,23 @@ if sys.version_info >= (3, 11):
6363
if sys.version_info >= (3, 12):
6464
__all__ += ["getHandlerByName", "getHandlerNames"]
6565

66-
class _SupportsFilter(Protocol):
67-
if sys.version_info >= (3, 12):
68-
def filter(self, record: LogRecord) -> bool | LogRecord: ...
69-
else:
70-
def filter(self, record: LogRecord) -> bool: ...
71-
7266
_SysExcInfoType: TypeAlias = tuple[type[BaseException], BaseException, TracebackType | None] | tuple[None, None, None]
7367
_ExcInfoType: TypeAlias = None | bool | _SysExcInfoType | BaseException
7468
_ArgsType: TypeAlias = tuple[object, ...] | Mapping[str, object]
75-
_FilterType: TypeAlias = _SupportsFilter | Callable[[LogRecord], bool]
7669
_Level: TypeAlias = int | str
7770
_FormatStyle: TypeAlias = Literal["%", "{", "$"]
7871

72+
if sys.version_info >= (3, 12):
73+
class _SupportsFilter(Protocol):
74+
def filter(self, record: LogRecord) -> bool | LogRecord: ...
75+
76+
_FilterType: TypeAlias = Filter | Callable[[LogRecord], bool | LogRecord] | _SupportsFilter
77+
else:
78+
class _SupportsFilter(Protocol):
79+
def filter(self, record: LogRecord) -> bool: ...
80+
81+
_FilterType: TypeAlias = Filter | Callable[[LogRecord], bool] | _SupportsFilter
82+
7983
raiseExceptions: bool
8084
logThreads: bool
8185
logMultiprocessing: bool

0 commit comments

Comments
 (0)