GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add CI step for checking redundant test patches (#7126) · RustPython/RustPython@64088bb

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • ci.yaml
  • scripts
    • check_redundant_patches.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/ci.yaml‎

Copy file name to clipboardExpand all lines: .github/workflows/ci.yaml
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,17 @@ jobs:
456456
run: python -I scripts/whats_left.py --no-default-features --features "$(sed -e 's/--[^ ]*//g' <<< "${{ env.CARGO_ARGS }}" | tr -d '[:space:]'),threading" # no jit on macOS for now
457457

458458
lint:
459-
name: Check Rust code with clippy
459+
name: Lint Rust & Python code
460460
runs-on: ubuntu-latest
461461
steps:
462462
- uses: actions/[email protected]
463+
- uses: actions/[email protected]
464+
with:
465+
python-version: ${{ env.PYTHON_VERSION }}
466+
467+
- name: Check for redundant test patches
468+
run: python scripts/check_redundant_patches.py
469+
463470
- uses: dtolnay/rust-toolchain@stable
464471
with:
465472
components: clippy
Collapse file

‎scripts/check_redundant_patches.py‎

Copy file name to clipboard
+52Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python
2+
import ast
3+
import pathlib
4+
import sys
5+
6+
ROOT = pathlib.Path(__file__).parents[1]
7+
TEST_DIR = ROOT / "Lib" / "test"
8+
9+
10+
def main():
11+
exit_status = 0
12+
for file in TEST_DIR.rglob("**/*.py"):
13+
try:
14+
contents = file.read_text(encoding="utf-8")
15+
except UnicodeDecodeError:
16+
continue
17+
18+
try:
19+
tree = ast.parse(contents)
20+
except SyntaxError:
21+
continue
22+
23+
for node in ast.walk(tree):
24+
if not isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
25+
continue
26+
27+
name = node.name
28+
if not name.startswith("test"):
29+
continue
30+
31+
if node.decorator_list:
32+
continue
33+
34+
func_code = ast.unparse(node.body)
35+
if func_code in (
36+
f"await super().{name}()",
37+
f"return await super().{name}()",
38+
f"return super().{name}()",
39+
f"super().{name}()",
40+
):
41+
exit_status += 1
42+
rel = file.relative_to(ROOT)
43+
lineno = node.lineno
44+
print(
45+
f"{rel}:{name}:{lineno} is a test patch that can be safely removed",
46+
file=sys.stderr,
47+
)
48+
return exit_status
49+
50+
51+
if __name__ == "__main__":
52+
exit(main())

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.