🚀 Duplicate File Cleaner (with 100% Test Coverage)
A fast and secure Python command-line utility (CLI) for finding and removing duplicate files. This project is built with strict type annotations, system error handling, and full test coverage.
🌟 Features
- 100% Code Coverage: Every part of the application, including empty directory cleanup, interactive choices, and edge cases, is tested.
- Isolated Testing: Robust handling of system exceptions such as symlink loops (
ELOOP) and permission errors (EACCES) via mocking. - Scan workflow: Identifies duplicate files efficiently by grouping them by size first, then calculating SHA-256 chunked hashes for verification.
🛠 Stack & Tools
- Language: Python 3.12+ (with strict
typingannotations) - Environment & Package Manager:
uv - Testing Framework:
pytest - Coverage Tool:
pytest-cov - Reporting:
allure-pytest
📦 Code Coverage Metrics
Run the coverage tool directly using the customized default test runner. The project has zero coverage gaps:
| File | Stmts | Miss | Branch | BrPart | Cover |
|---|---|---|---|---|---|
src/duplicate_cleaner/__init__.py |
8 | 0 | 0 | 0 | 100.0% |
src/duplicate_cleaner/duplicate_cleaner.py |
151 | 0 | 60 | 0 | 100.0% |
| TOTAL | 159 | 0 | 60 | 0 | 100.0% |
Verified Edge Cases:
- Circular Symlinks (
ELOOP): Validated protection loops against recursive symlinks during depth detection and link flattening. - Relative Symlink Targets: Correct resolution of target paths when symlinks point to relative locations (
../). - Permission Errors (
EACCES): Ensures locked or system files are safely skipped and logged without crashing the tool. - Interactive Prompts and Flags: Complete parameter mapping for CLI combinations like
--no-confirm,--remove-empty, and user inputs (y/N).
🚀 Quick Start
1. Installation and Setup
Project dependencies are managed via uv. Clone the repository and run the setup command in the project root:
uv sync
This command creates an isolated virtual environment and automatically installs all dependencies.
2. Running the Utility
Execute the application entry point using uv run:
# Basic run (scans user home directory by default)
uv run duplicate-cleaner
# Scan a specific directory recursively with auto-confirmation and empty directory cleanup
uv run duplicate-cleaner --target . --recurse --no-confirm --remove-empty
🧪 Testing & Reporting
Thanks to pre-configured addopts project settings, short logs, test execution coverage metrics collection, and Allure report indexing run automatically.
Run Tests and Collect Coverage
uv run pytest
This instantly executes tests, renders an HTML report in htmlcov/, and updates text metrics.
Generate Allure Reports
Build and view the dashboard in your default browser (requires a local installation of allure-cli):
allure serve allure-results
⚙️ Code Quality & Linters
The codebase complies with modern standard formatting guidelines. Code styles are validated with Ruff:
# Check code style, formatting, and imports
uv run ruff check
# Automatically format the code to PEP 8 standards
uv run ruff format
Run static type checking using mypy:
uv run mypy src/ tests/
Metadata
Release files for duplicate-cleaner 0.1.2
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 | Actions |
|---|---|---|---|---|
| duplicate_cleaner-0.1.2.tar.gz | 5.3 kB | Without provenance | Details for duplicate_cleaner-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| duplicate_cleaner-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for duplicate_cleaner-0.1.2-py3-none-any.whl |
Total release size: 11.2 kB
Release files / duplicate_cleaner-0.1.2.tar.gz
| Download URL | duplicate_cleaner-0.1.2.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
01b6305f1c42d1a517983e0d7112d0bb6db23de53881430e901198e270054939
|
|
BLAKE2b-256 checksum How to use checksums |
641514130bb4a04693561dd26cd3af9d5df9207331a73db88c03f6f5b7d13ea3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / duplicate_cleaner-0.1.2-py3-none-any.whl
| Download URL | duplicate_cleaner-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14060aaf9d9a05b86b3698d4e8fa780582310fa09d1c860a5dd795d7205f8222
|
|
BLAKE2b-256 checksum How to use checksums |
25b3ad050b01bb5aef5ff56f9b3c314c8b22eba4ba7259353675d9ea06f65dad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for duplicate-cleaner 0.1.2
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.