Skip to content

Commit 77264db

Browse files
Fix: Cleaning
1 parent 7765c34 commit 77264db

File tree

9 files changed

+11
-41
lines changed

9 files changed

+11
-41
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
This project provides simple tools to compare the content of a directory against a reference
1111
directory.
1212

13-
This is useful to check the results of a process that generate several files, like a luigi
13+
This is useful to check the results of a process that generates several files, like a luigi
1414
workflow for example.
1515

1616

dir_content_diff/__init__.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@
1414

1515
import importlib.metadata
1616

17-
# Import base comparators for backward compatibility
17+
# Import base comparators
1818
from dir_content_diff.base_comparators import BaseComparator
1919
from dir_content_diff.base_comparators import DefaultComparator
2020

21-
# from dir_content_diff.core import _DEFAULT_EXPORT_SUFFIX
22-
# from dir_content_diff.core import _check_config
23-
# from dir_content_diff.core import _split_into_chunks
2421
# Import core comparison functionality
2522
from dir_content_diff.config import ComparisonConfig
2623
from dir_content_diff.core import ComparatorType
@@ -31,18 +28,11 @@
3128
from dir_content_diff.core import pick_comparator
3229

3330
# Import comparator registry functionality
34-
# from dir_content_diff.registry import _COMPARATORS
3531
from dir_content_diff.registry import get_comparators
3632
from dir_content_diff.registry import register_comparator
3733
from dir_content_diff.registry import reset_comparators
3834
from dir_content_diff.registry import unregister_comparator
3935

40-
# from dir_content_diff.base_comparators import IniComparator
41-
# from dir_content_diff.base_comparators import JsonComparator
42-
# from dir_content_diff.base_comparators import PdfComparator
43-
# from dir_content_diff.base_comparators import XmlComparator
44-
# from dir_content_diff.base_comparators import YamlComparator
45-
4636
__version__ = importlib.metadata.version("dir-content-diff")
4737

4838
# For backward compatibility, ensure all public functions are available
@@ -60,13 +50,4 @@
6050
"unregister_comparator",
6151
"BaseComparator",
6252
"DefaultComparator",
63-
# "IniComparator",
64-
# "JsonComparator",
65-
# "PdfComparator",
66-
# "XmlComparator",
67-
# "YamlComparator",
68-
# "_DEFAULT_EXPORT_SUFFIX",
69-
# "_split_into_chunks",
70-
# "_check_config",
71-
# "_COMPARATORS",
7253
]

dir_content_diff/base_comparators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ def _cast_from_attribute(text, attr):
513513
elif str(text).lower() == "false":
514514
res = False
515515
else:
516-
raise ValueError("Bool attributes expect 'true' or 'false'.")
516+
raise ValueError("Boolean attributes expect 'true' or 'false'.")
517517
elif value_type == "list":
518518
res = []
519519
elif value_type == "dict":

dir_content_diff/config.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import attrs
2727

2828
from dir_content_diff.base_comparators import BaseComparator
29+
from dir_content_diff.registry import get_comparators
2930

3031
# Type alias for comparators
3132
ComparatorType = Union[BaseComparator, Callable]
@@ -150,9 +151,6 @@ class ComparisonConfig:
150151

151152
def __attrs_post_init__(self):
152153
"""Initialize computed fields after attrs initialization."""
153-
# Import here to avoid circular imports
154-
from dir_content_diff.registry import get_comparators
155-
156154
# Validate and compile patterns - with frozen, we compile once and store directly
157155
try:
158156
compiled_include = self._compile_patterns(self.include_patterns)

dir_content_diff/core.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,11 @@
1414

1515
import copy
1616
import os
17-
import re
1817
from collections.abc import Callable
1918
from concurrent.futures import ProcessPoolExecutor
2019
from concurrent.futures import ThreadPoolExecutor
2120
from pathlib import Path
22-
from typing import Any
23-
from typing import Dict
24-
from typing import Iterable
25-
from typing import List
26-
from typing import Literal
2721
from typing import Optional
28-
from typing import Pattern
2922
from typing import Tuple
3023
from typing import Union
3124

@@ -47,8 +40,6 @@
4740
_DEFAULT_EXPORT_SUFFIX = "_FORMATTED"
4841

4942

50-
51-
5243
def compare_files(
5344
ref_file: Union[str, Path],
5445
comp_file: Union[str, Path],
@@ -368,6 +359,7 @@ def compare_trees(
368359
config,
369360
comp_path,
370361
formatted_data_path,
362+
_compare_single_file,
371363
): chunk
372364
for chunk in file_chunks
373365
if chunk # Skip empty chunks

dir_content_diff/parallel_utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def _compare_file_chunk(
5151
config: ComparisonConfig,
5252
comp_path: Path,
5353
formatted_data_path: Path,
54+
compare_single_file_func,
5455
) -> List[Tuple[str, Union[str, bool]]]: # pragma: no cover
5556
"""Compare a chunk of files.
5657
@@ -59,17 +60,15 @@ def _compare_file_chunk(
5960
config: Comparison configuration.
6061
comp_path: Path to the comparison directory.
6162
formatted_data_path: Path where formatted files should be exported.
63+
compare_single_file_func: Function to compare a single file.
6264
6365
Returns:
6466
List of comparison results for the chunk.
6567
"""
66-
# Import here to avoid circular imports
67-
from dir_content_diff.core import _compare_single_file
68-
6968
results = []
7069
for ref_file, relative_path in file_chunk:
7170
try:
72-
result = _compare_single_file(
71+
result = compare_single_file_func(
7372
ref_file, comp_path, relative_path, config, formatted_data_path
7473
)
7574
results.append(result)

dir_content_diff/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def import_error_message(name):
170170
dependencies = COMPARATOR_DEPENDENCIES[name]
171171
except KeyError as exception:
172172
msg = (
173-
f"The module {name} has no registered dependency, please add dependencies in the "
173+
f"The module {name} has no registered dependency, please add dependencies to the "
174174
"dependencies.json file"
175175
)
176176
raise KeyError(msg) from exception

tests/test_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ def test_xmltodict(self):
623623

624624
# Test bad value in boolean
625625
with pytest.raises(
626-
ValueError, match="Bool attributes expect 'true' or 'false'."
626+
ValueError, match="Boolean attributes expect 'true' or 'false'."
627627
):
628628
comparator.xmltodict(
629629
"""<?xml version="1.0" encoding="UTF-8" ?>"""

tests/test_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_import_error_message(monkeypatch, caplog):
2828
with pytest.raises(
2929
KeyError,
3030
match=(
31-
"The module UNKNOWN_MODULE has no registered dependency, please add dependencies in "
31+
"The module UNKNOWN_MODULE has no registered dependency, please add dependencies to "
3232
"the dependencies.json file"
3333
),
3434
):

0 commit comments

Comments
 (0)