Skip to content

Commit 8f3c024

Browse files
committed
ci-bump-version
1 parent 57fc671 commit 8f3c024

4 files changed

Lines changed: 48 additions & 10 deletions

File tree

codeconcat/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def parse_arguments() -> argparse.Namespace:
2020
"""Parses command line arguments."""
2121
parser = argparse.ArgumentParser(
2222
description=(
23-
"Concatenate files from a directory into a single output, " "respecting .gitignore and config files."
23+
"Concatenate files from a directory into a single output, "
24+
"respecting .gitignore and config files."
2425
),
2526
formatter_class=argparse.ArgumentDefaultsHelpFormatter, # Show defaults
2627
)
@@ -74,7 +75,9 @@ def main() -> None:
7475

7576
# Determine final settings, command-line args override config file
7677
use_gitignore = (
77-
not args.no_gitignore if args.no_gitignore else config.get("use_gitignore", DEFAULT_CONFIG["use_gitignore"])
78+
not args.no_gitignore
79+
if args.no_gitignore
80+
else config.get("use_gitignore", DEFAULT_CONFIG["use_gitignore"])
7881
)
7982
# Combine patterns from config and args, ensuring args take precedence if provided
8083
config_exclude = config.get("exclude_patterns", DEFAULT_CONFIG["exclude_patterns"])

codeconcat/output.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ def create_output(
6363
output_stream.write("\n\n")
6464
# --- End of Formatting Change ---
6565

66-
logger.info(f"Successfully wrote {len(tree)} files to " f"{'stdout' if to_stdout else output_path_str}")
66+
logger.info(
67+
f"Successfully wrote {len(tree)} files to " f"{'stdout' if to_stdout else output_path_str}"
68+
)
6769

6870
except OSError as e:
6971
logger.error(f"Error writing to output {'stdout' if to_stdout else output_path_str}. " f"Error: {e}")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ test = [
5757

5858
# --- Ruff Configuration ---
5959
[tool.ruff]
60-
line-length = 88
60+
line-length = 110
6161
target-version = "py310"
6262

6363
[tool.ruff.lint]

tests/test_main.py

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,23 @@ def test_exclude_flag(tmp_path: Path):
7979
"""Test the --exclude command-line flag."""
8080
source_dir = tmp_path / "src"
8181
output_file = tmp_path / "output.txt"
82-
create_test_files(source_dir, {"include.py": "include", "exclude.log": "exclude", "also_include.txt": "include 2"})
82+
create_test_files(
83+
source_dir,
84+
{
85+
"include.py": "include",
86+
"exclude.log": "exclude",
87+
"also_include.txt": "include 2",
88+
},
89+
)
8390

8491
# Simulate command line: codeconcat ./src output.txt --exclude ".*\\.log$"
85-
test_args = ["codeconcat", str(source_dir), str(output_file), "--exclude", r".*\.log$"]
92+
test_args = [
93+
"codeconcat",
94+
str(source_dir),
95+
str(output_file),
96+
"--exclude",
97+
r".*\.log$",
98+
]
8699
with patch.object(sys, "argv", test_args):
87100
main()
88101

@@ -97,10 +110,23 @@ def test_whitelist_flag(tmp_path: Path):
97110
"""Test the --whitelist command-line flag."""
98111
source_dir = tmp_path / "src"
99112
output_file = tmp_path / "output.txt"
100-
create_test_files(source_dir, {"include.py": "include", "exclude.txt": "exclude", "also_include.py": "include 2"})
113+
create_test_files(
114+
source_dir,
115+
{
116+
"include.py": "include",
117+
"exclude.txt": "exclude",
118+
"also_include.py": "include 2",
119+
},
120+
)
101121

102122
# Simulate command line: codeconcat ./src output.txt --whitelist "\.py$"
103-
test_args = ["codeconcat", str(source_dir), str(output_file), "--whitelist", r"\.py$"]
123+
test_args = [
124+
"codeconcat",
125+
str(source_dir),
126+
str(output_file),
127+
"--whitelist",
128+
r"\.py$",
129+
]
104130
with patch.object(sys, "argv", test_args):
105131
main()
106132

@@ -191,7 +217,11 @@ def test_config_file_loading_home_only(mock_load_config, tmp_path: Path):
191217
)
192218

193219
# Define what load_config_file should return for home and project paths
194-
home_config_content = {"use_gitignore": False, "exclude_patterns": [r"\.log$"], "whitelist_patterns": []}
220+
home_config_content = {
221+
"use_gitignore": False,
222+
"exclude_patterns": [r"\.log$"],
223+
"whitelist_patterns": [],
224+
}
195225

196226
def load_side_effect(path):
197227
if path == HOME_CONFIG_PATH:
@@ -265,7 +295,10 @@ def test_no_files_found(tmp_path: Path, caplog):
265295
output_file = tmp_path / "output.txt"
266296

267297
test_args = ["codeconcat", str(source_dir), str(output_file)]
268-
with patch.object(sys, "argv", test_args), caplog.at_level(logging.WARNING): # Capture warnings
298+
with (
299+
patch.object(sys, "argv", test_args),
300+
caplog.at_level(logging.WARNING),
301+
): # Capture warnings
269302
main()
270303

271304
assert not output_file.exists() # Should not create empty file

0 commit comments

Comments
 (0)