diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2023-01-01 07:42:00 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2023-01-01 07:42:00 -0500 |
commit | 8f4d404c8f9044ea1c3bf2479236f51d7706cb76 (patch) | |
tree | a3b5d2d58edaa15a37bff9aa2f1b4fcbba39dcdb /coverage/env.py | |
parent | a3f3841b746a1789ff8f7fea0cc0715c45770996 (diff) | |
download | python-coveragepy-git-8f4d404c8f9044ea1c3bf2479236f51d7706cb76.tar.gz |
refactor: a better way to filter `coverage debug pybehave`
Diffstat (limited to 'coverage/env.py')
-rw-r--r-- | coverage/env.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/coverage/env.py b/coverage/env.py index 0b01f3e7..c6c1ed13 100644 --- a/coverage/env.py +++ b/coverage/env.py @@ -9,6 +9,13 @@ import sys from typing import Any, Iterable, Tuple +# debug_info() at the bottom wants to show all the globals, but not imports. +# Grab the global names here to know which names to not show. Nothing defined +# above this line will be in the output. +_UNINTERESTING_GLOBALS = list(globals()) +# These names also shouldn't be shown. +_UNINTERESTING_GLOBALS += ["PYBEHAVIOR", "debug_info"] + # Operating systems. WINDOWS = sys.platform == "win32" LINUX = sys.platform.startswith("linux") @@ -140,10 +147,7 @@ def debug_info() -> Iterable[Tuple[str, Any]]: """Return a list of (name, value) pairs for printing debug information.""" info = [ (name, value) for name, value in globals().items() - if not name.startswith("_") and - name not in {"PYBEHAVIOR", "debug_info"} and - not isinstance(value, type(os)) and - not str(value).startswith("typing.") + if not name.startswith("_") and name not in _UNINTERESTING_GLOBALS ] info += [ (name, value) for name, value in PYBEHAVIOR.__dict__.items() |