reinvent-check
Finds Python functions that were written twice under different names. Paste several files below (start each with a # file: name.py line) or load .py files from disk, then run. Everything runs in your browser with Pyodide; no code is uploaded.
Python is loading (about 10 MB, once).
How it decides two functions are the same
- Each function is parsed with Python's own
astmodule. The docstring, decorators, type hints and line numbers are dropped. - Arguments and local variables are renamed by order of first use, so
total_due(items, tax_rate)andorder_value(lines, vat)collapse to the same tree. - Globals, called helpers, attribute names and constants keep their names, so the same shape calling a different helper is not a match.
- Limit: exact structure only. Reordered statements or one changed constant are not reported.
Command line
uv run main.py src/ --min-nodes 12prints the groups;--jsonfor machine output.- Exit code 1 when duplicates exist, so it can gate CI. Folders named
vendor,.venv,site-packagesandnode_modulesare skipped. - The source is shown below; it is the exact file this page runs.