Skip to content

Commit 4e2c733

Browse files
committed
Fmt
1 parent 75e6827 commit 4e2c733

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

src/dda/cli/validate/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ def cmd() -> None:
1313
"""
1414
Validate tools and utilities for development workflow.
1515
"""
16-
pass

src/dda/cli/validate/ai_rules/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
# SPDX-License-Identifier: MIT
44
from __future__ import annotations
55

6-
import os
76
from typing import TYPE_CHECKING
87

98
import click
10-
from dda.utils.diff import pretty_diff
119

1210
from dda.cli.base import dynamic_command, pass_app
11+
from dda.utils.diff import pretty_diff
1312
from dda.utils.fs import Path
1413

1514
if TYPE_CHECKING:
@@ -18,6 +17,7 @@
1817
CURSOR_RULES_DIR = Path(".cursor/rules")
1918
TARGETS_FILES = [Path("CLAUDE.md")]
2019

20+
2121
@dynamic_command(short_help="Validate AI rules are coherent between all the coding agent config files")
2222
@click.option(
2323
"--fix",
@@ -46,7 +46,7 @@ def cmd(app: Application, *, should_fix: bool) -> None:
4646
new_content = generate_content(rule_files, target_file)
4747
old_content = ""
4848
if target_file.exists() and target_file.is_file():
49-
with open(target_file, "r", encoding="utf-8") as f:
49+
with open(target_file, encoding="utf-8") as f:
5050
old_content = f.read()
5151
diff = pretty_diff(old_content, new_content)
5252
if not diff:
@@ -58,15 +58,16 @@ def cmd(app: Application, *, should_fix: bool) -> None:
5858
f.write(new_content)
5959
app.display_success(f"Successfully fixed {target_file}")
6060
else:
61-
unsynced_targets.append(str(target_file))
61+
unsynced_targets.append(str(target_file))
6262
if unsynced_targets:
6363
app.display_error(f"The following targets are not in sync: {', '.join(unsynced_targets)}")
6464
app.abort()
6565
app.display_success("All targets are in sync")
6666

67+
6768
def get_rule_files(cursor_rules_dir: Path) -> list[Path]:
6869
"""Find all rule files in cursor rules directory (recursively), excluding personal rules."""
69-
return sorted(rule for rule in cursor_rules_dir.glob('**/*.mdc') if "personal" not in rule.parts)
70+
return sorted(rule for rule in cursor_rules_dir.glob("**/*.mdc") if "personal" not in rule.parts)
7071

7172

7273
def generate_content(rule_files: list[Path], target_file: Path) -> str:

src/dda/utils/diff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import difflib
22

33

4-
def pretty_diff(string1, string2) -> str:
4+
def pretty_diff(string1: str, string2: str) -> str:
55
lines1 = string1.splitlines()
66
lines2 = string2.splitlines()
77

@@ -15,4 +15,4 @@ def pretty_diff(string1, string2) -> str:
1515
result.append(f"\033[32m{line}\033[0m") # Green for additions
1616
else:
1717
result.append(line)
18-
return '\n'.join(result)
18+
return "\n".join(result)

tests/cli/validate/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# SPDX-FileCopyrightText: 2025-present Datadog, Inc. <dev@datadoghq.com>
22
#
3-
# SPDX-License-Identifier: MIT
3+
# SPDX-License-Identifier: MIT

tests/cli/validate/test_ai-rules.py renamed to tests/cli/validate/test_ai_rules.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33
# SPDX-License-Identifier: MIT
44
from __future__ import annotations
55

6-
import os
76
import shutil
87
from typing import TYPE_CHECKING
9-
from dda.utils.fs import Path
108

119
import pytest
1210

11+
from dda.utils.fs import Path
12+
1313
if TYPE_CHECKING:
1414
from collections.abc import Callable
1515

1616
from tests.conftest import CliRunner
1717

1818

19-
2019
@pytest.fixture(name="use_temp_fixture_folder")
21-
def fixt_use_temp_folder(temp_dir: Path):
22-
def _use_temp_folder(folder_name: str):
23-
shutil.copytree(Path((__file__)).parent / "fixtures" / "ai_rules" / folder_name, temp_dir / folder_name)
20+
def fixt_use_temp_folder(temp_dir: Path) -> Callable[[str], Path]:
21+
def _use_temp_folder(folder_name: str) -> Path:
22+
shutil.copytree(Path(__file__).parent / "fixtures" / "ai_rules" / folder_name, temp_dir / folder_name)
2423
return Path(temp_dir) / folder_name
24+
2525
return _use_temp_folder
2626

2727

@@ -50,13 +50,13 @@ def test_validate_with_fix_flag(
5050
result.check_exit_code(exit_code=0)
5151
assert (path / "CLAUDE.md").exists()
5252
content = (path / "CLAUDE.md").read_text(encoding="utf-8")
53-
assert f"@.cursor/rules/coding-standards.mdc" in content
54-
assert f"@.cursor/rules/security.mdc" in content
55-
assert f"@.cursor/rules/testing.mdc" in content
56-
assert f"imhere.txt" not in content
57-
assert f"@.cursor/rules/personal/my-rule.mdc" not in content
58-
assert f"@.cursor/rules/nested/my-nested-rule.mdc" in content
59-
assert f"@CLAUDE_PERSONAL.md" in content
53+
assert "@.cursor/rules/coding-standards.mdc" in content
54+
assert "@.cursor/rules/security.mdc" in content
55+
assert "@.cursor/rules/testing.mdc" in content
56+
assert "imhere.txt" not in content
57+
assert "@.cursor/rules/personal/my-rule.mdc" not in content
58+
assert "@.cursor/rules/nested/my-nested-rule.mdc" in content
59+
assert "@CLAUDE_PERSONAL.md" in content
6060

6161

6262
def test_validate_no_cursor_rules_directory(

0 commit comments

Comments
 (0)