From 45ef87bcb43be51383fdb43b4595a00cdc61f00d Mon Sep 17 00:00:00 2001 From: Athanasius Date: Tue, 28 Jul 2020 09:19:34 +0100 Subject: [PATCH] Correct frame typing, and import clean up. Also explains why we're doing that _getframe import that way. --- EDMCLogging.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/EDMCLogging.py b/EDMCLogging.py index a8fb45df..15a29286 100644 --- a/EDMCLogging.py +++ b/EDMCLogging.py @@ -5,14 +5,13 @@ members on the logging.LogRecord instance for use in logging.Formatter() strings. """ +# So that any warning about accessing a protected member is only in one place. from sys import _getframe as getframe import inspect import logging -from typing import TYPE_CHECKING, Tuple +from typing import Tuple -# if TYPE_CHECKING: - # TODO: Tests: # # 1. Call from bare function in file. @@ -130,7 +129,7 @@ class EDMCContextFilter(logging.Filter): # Go up through stack frames until we find the first with a # type(f_locals.self) of logging.Logger. This should be the start # of the frames internal to logging. - frame: 'frameobject' = getframe(0) + frame: 'frame' = getframe(0) while frame: if isinstance(frame.f_locals.get('self'), logging.Logger): frame = frame.f_back # Want to start on the next frame below