Skip to content

Commit c9546c2

Browse files
authored
Don't run whats_left with older CPython versions (RustPython#4847)
* Improve whats_left --signature output
1 parent 2a1b2ed commit c9546c2

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

whats_left.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@
3434

3535
implementation = platform.python_implementation()
3636
if implementation != "CPython":
37-
sys.exit("whats_left.py must be run under CPython, got {implementation} instead")
38-
37+
sys.exit(f"whats_left.py must be run under CPython, got {implementation} instead")
38+
if sys.version_info[:2] < (3, 11):
39+
sys.exit(f"whats_left.py must be run under CPython 3.11 or newer, got {implementation} {sys.version} instead")
3940

4041
def parse_args():
4142
parser = argparse.ArgumentParser(description="Process some integers.")
@@ -483,11 +484,17 @@ def remove_one_indent(s):
483484
if args.signature:
484485
print("\n# mismatching signatures (warnings)")
485486
for modname, mismatched in result["mismatched_items"].items():
486-
for (item, rustpy_value, cpython_value) in mismatched:
487-
if cpython_value == "ValueError('no signature found')":
488-
continue # these items will never match
489-
490-
print(f"{item} {rustpy_value} != {cpython_value}")
487+
for i, (item, rustpy_value, cpython_value) in enumerate(mismatched):
488+
if cpython_value and cpython_value.startswith("ValueError("):
489+
continue # these items will never match
490+
if rustpy_value is None or rustpy_value.startswith("ValueError("):
491+
rustpy_value = f" {rustpy_value}"
492+
print(f"{item}{rustpy_value}")
493+
if cpython_value is None:
494+
cpython_value = f" {cpython_value}"
495+
print(f"{' ' * len(item)}{cpython_value}")
496+
if i < len(mismatched) - 1:
497+
print()
491498

492499
if args.doc:
493500
print("\n# mismatching `__doc__`s (warnings)")

0 commit comments

Comments
 (0)