check-duplicate-variables
A Python tool that detects duplicate variable names within the same scope (module or class) in Python files. Useful for finding copy-paste errors, refactoring issues, and keeping code quality in check (e.g. in page object models).
Features
- AST-based analysis – Uses Python’s AST for accurate parsing
- Scope-aware – Detects duplicates at module and class scope
- Value comparison – Reports whether duplicate assignments have the same or different values
- Multiple assignment types – Handles normal assignments, type-annotated assignments, tuple unpacking, and attribute assignments
- Recursive scanning – Scans all
.pyfiles under a directory - CI-friendly – Exit codes and formatted output for pipelines
Installation
pip install check-duplicate-variables
Requirements: Python 3.8+
Usage
Default (scans a pageobjects directory in the current directory):
check-duplicate-variables
Custom path:
check-duplicate-variables /path/to/your/python/files
As a module:
python -m check-duplicate-variables [directory]
# or
python -m check-duplicate-variables [filepath]
Exit codes: 0 – no duplicates / no errors; 1 – duplicates found or errors.
Output
One line per duplicate:
file_path: variable_name (same values) - line1, line2, line3
file_path: variable_name (different values) - line1, line2
- (same values) – All assignments have the same value (possible copy-paste)
- (different values) – Assignments differ (reassignment or possible bug)
License
MIT – see LICENSE.
Metadata
Release files for check-duplicate-variables 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| check_duplicate_variables-1.0.5.tar.gz | 12.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| check_duplicate_variables-1.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.5 kB
Release files / check_duplicate_variables-1.0.5.tar.gz
| Download URL | check_duplicate_variables-1.0.5.tar.gz |
|---|---|
| Size | 12.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7d416face45f9b4b3ae57014f296013462a265c3e7377763d74ad4b792e062c
|
|
BLAKE2b-256 checksum How to use checksums |
b616868e19787221ddd6aac02eb28d21125e60844731772076cef05867cb1419
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / check_duplicate_variables-1.0.5-py3-none-any.whl
| Download URL | check_duplicate_variables-1.0.5-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f11349c42629be478526e4cad066ac0ef101056ec948e2164bd1d9891330e38f
|
|
BLAKE2b-256 checksum How to use checksums |
356dea0f6415fae246eceae7bfd2fb92becea4731be22b193dea8aeb96d4c275
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for check-duplicate-variables 1.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.