From 4178c4061712cadfd0fb8cbc7bd97a4df4f5a4ea Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Mon, 26 Feb 2018 23:35:26 +0000 Subject: [PATCH] core: Add docstring to is_blacklisted_import() This documents the existing behaviour, which may not be the intended. --- mitogen/core.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mitogen/core.py b/mitogen/core.py index d8ffbb13..0bd75b6b 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -168,6 +168,14 @@ def restart(func, *args): def is_blacklisted_import(importer, fullname): + """Return ``True`` if `fullname` is part of a blacklisted package, or if + any packages have been whitelisted and `fullname` is not part of one. + + NB: + - If a package is on both lists, then it is treated as blacklisted. + - If any package is whitelisted, then all non-whitelisted packages are + treated as blacklisted. + """ return ((not any(fullname.startswith(s) for s in importer.whitelist)) or (any(fullname.startswith(s) for s in importer.blacklist)))