Skip to main content

🚀 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 typing annotations)
  • 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:

  1. Circular Symlinks (ELOOP): Validated protection loops against recursive symlinks during depth detection and link flattening.
  2. Relative Symlink Targets: Correct resolution of target paths when symlinks point to relative locations (../).
  3. Permission Errors (EACCES): Ensures locked or system files are safely skipped and logged without crashing the tool.
  4. 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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for duplicate-cleaner 0.1.0
File Size Uploaded Provenance Actions
duplicate_cleaner-0.1.0.tar.gz 5.3 kB Without provenance Details for duplicate_cleaner-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for duplicate-cleaner 0.1.0
File Interpreter ABI Platform Actions
duplicate_cleaner-0.1.0-py3-none-any.whl Python 3 none any Details for duplicate_cleaner-0.1.0-py3-none-any.whl

Total release size: 11.2 kB

Release files / duplicate_cleaner-0.1.0.tar.gz

Download URL duplicate_cleaner-0.1.0.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
02f51a786d17db5a4742651a665e7438e334fdfb470cddc2f6c56406ef00245e
BLAKE2b-256 checksum
How to use checksums
cae4e669129c825bb67f249d07a6564097e4e13d5852e640cab308ad468dd924
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.0-py3-none-any.whl

Download URL duplicate_cleaner-0.1.0-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
40d74bc284c95f22137260eaba9c1b7be69b0fe2f2eaa05a49fd116b31c24a0d
BLAKE2b-256 checksum
How to use checksums
b3d9b811937a60a37991884626446224c54b18bfd3df2e1daaef3dd6ebaad43f
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.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page