aboutsummaryrefslogtreecommitdiff
path: root/duplicate_finder/types.py
diff options
context:
space:
mode:
authorDennis Fink2026-09-20 20:04:13 +0200
committerDennis Fink2026-09-20 20:04:13 +0200
commitb751174b4ed7c23786ae54a1bbaf332f653faa81 (patch)
treec1951961b7bdd171aa4903d9e2d5ad4f2a063b51 /duplicate_finder/types.py
downloadduplicate-finder-main.tar.gz
duplicate-finder-main.zip
feat: release duplicate-finder 1.0.0HEADv1.0.0main
Introduce the first public release of duplicate-finder, a command-line tool for detecting duplicate files through metadata grouping and content hashing. Support recursive path scanning, optional symlink traversal, hard-link handling, size and extension-based candidate grouping, and parallel content hashing with xxHash or hashlib algorithms. Provide human, plain, table, and JSON output formats together with size filtering, path input from files or stdin, progress reporting, diagnostic output, and configurable terminal colors. Add Python packaging for Python 3.14, project documentation, dependency locking, development tooling, and BSD-3-Clause licensing.
Diffstat (limited to 'duplicate_finder/types.py')
-rw-r--r--duplicate_finder/types.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/duplicate_finder/types.py b/duplicate_finder/types.py
new file mode 100644
index 0000000..f2438d8
--- /dev/null
+++ b/duplicate_finder/types.py
@@ -0,0 +1,36 @@
+# SPDX-FileCopyrightText: 2026 Dennis Fink <me+coding@dennisfink.me>
+#
+# SPDX-License-Identifier: BSD-3-Clause
+
+"""Types used throughout the duplicate-file finder."""
+
+from collections import defaultdict
+from dataclasses import dataclass
+from pathlib import Path
+
+type FileIdentity = tuple[int, int]
+type FileSize = int
+type FileHash = str
+type FileExtension = str
+
+
+@dataclass(frozen=True, slots=True)
+class FileInfo:
+ """Store filesystem metadata collected while discovering a file.
+
+ :param path: Path through which the file was discovered.
+ :param size: File size in bytes.
+ :param identity: Filesystem identity as ``(device, inode)``.
+ """
+
+ path: Path
+ size: FileSize
+ identity: FileIdentity
+
+
+type FileSet = set[FileInfo]
+type FilesByIdentity = defaultdict[FileIdentity, FileSet]
+
+type CandidateGroupKey = FileSize | tuple[FileSize, FileExtension]
+type FilesByCandidateGroup = dict[CandidateGroupKey, FilesByIdentity]
+type FilesByHash = dict[FileHash, FileSet]