From 6e123a219cdf94e783bd0833dc7249756a215537 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 14 May 2021 16:06:35 +0200 Subject: [PATCH 1/4] Add a comment about _typeshed to VERSIONS Support inline comments in VERSIONS --- stdlib/VERSIONS | 2 +- tests/check_consistent.py | 20 ++++++++++---------- tests/mypy_test.py | 24 ++++++++++++------------ 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/stdlib/VERSIONS b/stdlib/VERSIONS index 11219357c638..b6058e904d5a 100644 --- a/stdlib/VERSIONS +++ b/stdlib/VERSIONS @@ -45,7 +45,7 @@ _thread: 2.7- _threading_local: 3.6- _tkinter: 2.7- _tracemalloc: 3.6- -_typeshed: 2.7- +_typeshed: 2.7- # not present at runtime, only for type checking _warnings: 2.7- _weakref: 2.7- _weakrefset: 2.7- diff --git a/tests/check_consistent.py b/tests/check_consistent.py index ff8f20bcda3b..90791b852eff 100755 --- a/tests/check_consistent.py +++ b/tests/check_consistent.py @@ -105,16 +105,16 @@ def check_same_files(): def check_versions(): versions = set() with open("stdlib/VERSIONS") as f: - data = f.read().splitlines() - for line in data: - if not line or line.lstrip().startswith("#"): - continue - m = _VERSIONS_RE.match(line) - if not m: - raise AssertionError(f"Bad line in VERSIONS: {line}") - module = m.group(1) - assert module not in versions, f"Duplicate module {module} in VERSIONS" - versions.add(module) + for line in f: + line = line.split("#")[0].strip() + if line == "": + continue + m = _VERSIONS_RE.match(line) + if not m: + raise AssertionError(f"Bad line in VERSIONS: {line}") + module = m.group(1) + assert module not in versions, f"Duplicate module {module} in VERSIONS" + versions.add(module) modules = set() for entry in os.listdir("stdlib"): if entry == "@python2" or entry == "VERSIONS": diff --git a/tests/mypy_test.py b/tests/mypy_test.py index 349a61daceb7..b414338ad60d 100755 --- a/tests/mypy_test.py +++ b/tests/mypy_test.py @@ -75,19 +75,19 @@ def match(fn, args, exclude_list): def parse_versions(fname): - with open(fname) as f: - data = f.read().splitlines() result = {} - for line in data: - # Allow having some comments or empty lines. - if not line.strip() or line.startswith("#"): - continue - m = _VERSION_LINE_RE.match(line) - assert m, "invalid VERSIONS line :" + line - mod = m.group(1) - min_version = parse_version(m.group(2)) - max_version = parse_version(m.group(3)) if m.group(3) else (99, 99) - result[mod] = min_version, max_version + with open(fname) as f: + for line in f: + # Allow having some comments or empty lines. + line = line.split("#")[0].strip() + if line == "": + continue + m = _VERSION_LINE_RE.match(line) + assert m, "invalid VERSIONS line :" + line + mod = m.group(1) + min_version = parse_version(m.group(2)) + max_version = parse_version(m.group(3)) if m.group(3) else (99, 99) + result[mod] = min_version, max_version return result From 1f37190003af97771e92048acae8a0aa52ac7ccc Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 14 May 2021 16:08:16 +0200 Subject: [PATCH 2/4] Adjust format description --- stdlib/VERSIONS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/VERSIONS b/stdlib/VERSIONS index b6058e904d5a..c76cbeb0b4ee 100644 --- a/stdlib/VERSIONS +++ b/stdlib/VERSIONS @@ -1,5 +1,5 @@ # The structure of this file is as follows: -# - Blank lines and lines starting with `#` are ignored. +# - Blank lines and comments starting with `#` are ignored. # - Lines contain the name of a top-level module, followed by a colon, # a space, and a version range (for example: `symbol: 2.7-3.9`). # From d7794d65608c35820314015a2cd3dd49fa3aaad4 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Sun, 16 May 2021 22:34:34 +0200 Subject: [PATCH 3/4] fix typos --- tests/mypy_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/mypy_test.py b/tests/mypy_test.py index 05163cf886d1..8286d850edcd 100755 --- a/tests/mypy_test.py +++ b/tests/mypy_test.py @@ -83,7 +83,7 @@ def parse_versions(fname): if line == "": continue m = _VERSION_LINE_RE.match(line) - assert m, "invalid VERSIONS line :" + line + assert m, "invalid VERSIONS line: " + line mod = m.group(1) min_version = parse_version(m.group(2)) max_version = parse_version(m.group(3)) if m.group(3) else (99, 99) @@ -96,7 +96,7 @@ def parse_versions(fname): def parse_version(v_str): m = _VERSION_RE.match(v_str) - assert m, "invalid version :" + v_str + assert m, "invalid version: " + v_str return int(m.group(1)), int(m.group(2)) From 8f3a505a2009cce95ac51e6751ed68ea26e7a633 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 19 May 2021 10:30:39 +0200 Subject: [PATCH 4/4] Use newer mypy --- .github/workflows/mypy_primer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mypy_primer.yml b/.github/workflows/mypy_primer.yml index 0304c6d2786e..d9561c6b2699 100644 --- a/.github/workflows/mypy_primer.yml +++ b/.github/workflows/mypy_primer.yml @@ -44,7 +44,7 @@ jobs: # fail action if exit code isn't zero or one ( mypy_primer \ - --new 551eea3697 --old 551eea3697 \ + --new c605579af8 --old c605579af8 \ --custom-typeshed-repo typeshed_to_test \ --new-typeshed $GITHUB_SHA --old-typeshed upstream_master \ --num-shards 2 --shard-index ${{ matrix.shard-index }} \