Metadata-Version: 2.4
Name: check-duplicate-variables
Version: 1.0.5
Summary: Detect duplicate variable names within the same scope in Python files
Author: Pandiyaraj Karuppasamy
License-File: LICENSE
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# 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 `.py` files under a directory
- **CI-friendly** – Exit codes and formatted output for pipelines

## Installation

```bash
pip install check-duplicate-variables
```

**Requirements:** Python 3.8+

## Usage

Default (scans a `pageobjects` directory in the current directory):

```bash
check-duplicate-variables
```

Custom path:

```bash
check-duplicate-variables /path/to/your/python/files
```

As a module:

```bash
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](LICENSE).
