From c46993aa8eb1e049ad57d08e0d675357e6c203bc Mon Sep 17 00:00:00 2001 From: Matthias Kramm Date: Mon, 29 Aug 2016 14:23:39 -0700 Subject: [PATCH] Add mypy blacklist, same syntax as pytype blacklist. (#508) --- tests/mypy_blacklist.txt | 0 tests/mypy_test.py | 13 ++++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 tests/mypy_blacklist.txt diff --git a/tests/mypy_blacklist.txt b/tests/mypy_blacklist.txt new file mode 100644 index 000000000..e69de29bb diff --git a/tests/mypy_test.py b/tests/mypy_test.py index dc02246d1..55f0f45c2 100755 --- a/tests/mypy_test.py +++ b/tests/mypy_test.py @@ -32,7 +32,10 @@ def log(args, *varargs): print(*varargs) -def match(args, fn): +def match(fn, args, blacklist): + if blacklist.match(fn): + log(args, fn, 'exluded by blacklist') + return False if not args.filter and not args.exclude: log(args, fn, 'accept by default') return True @@ -70,6 +73,10 @@ def libpath(major, minor): def main(): args = parser.parse_args() + with open(os.path.join(os.path.dirname(__file__), "mypy_blacklist.txt")) as f: + blacklist = re.compile("(%s)$" % "|".join( + re.findall(r"^\s*([^\s#]+)\s*(?:#.*)?$", f.read(), flags=re.M))) + try: from mypy.main import main as mypy_main except ImportError: @@ -98,7 +105,7 @@ def main(): if mod in seen: continue if ext in ['.pyi', '.py']: - if match(args, full): + if match(full, args, blacklist): seen.add(mod) files.append(full) elif (os.path.isfile(os.path.join(full, '__init__.pyi')) or @@ -110,7 +117,7 @@ def main(): m, x = os.path.splitext(f) if x in ['.pyi', '.py']: fn = os.path.join(r, f) - if match(args, fn): + if match(fn, args, blacklist): seen.add(mod) files.append(fn) if files: