Skip to content

Commit 4c28ea9

Browse files
fix: remove dead deps, fix CI, clean unused imports
- Remove unused tomli-w dependency (never imported) - Remove redundant toml optional-dep group - Rename license optional-dep to licensing (remove duplicate) - Remove unused Syntax import from cli.py - Fix bare except blocks in loader.py (catch specific exceptions) - Fix CI branch trigger to main (matches default branch) - Fix CI coverage target to configdrift (was src)
1 parent 424060f commit 4c28ea9

3 files changed

Lines changed: 29 additions & 28 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: CI
22

33
on:
4-
push:
5-
branches: [main]
6-
pull_request:
7-
branches: [main]
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
88

99
jobs:
1010
test:
@@ -29,5 +29,5 @@ jobs:
2929
run: pip install ruff && ruff check src/ --target-version py310
3030
- name: Run tests
3131
run: |
32-
python -m pytest tests/ -v --cov=src --cov-report=term-missing
32+
python -m pytest tests/ -v --cov=configdrift --cov-report=term-missing
3333

pyproject.toml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,18 @@ classifiers = [
2222
"Programming Language :: Python :: 3.12",
2323
]
2424
dependencies = [
25-
"typer>=0.9.0",
26-
"rich>=13.0.0",
27-
"pyyaml>=6.0",
28-
"tomli>=2.0.0; python_version < '3.11'",
29-
"tomli-w>=1.0.0",
25+
"typer>=0.9.0",
26+
"rich>=13.0.0",
27+
"pyyaml>=6.0",
28+
"tomli>=2.0.0; python_version < '3.11'",
3029
]
3130

3231
[project.optional-dependencies]
32+
licensing = ["revenueholdings-license>=0.1.0"]
3333
dev = [
34-
"pytest>=7.0.0",
35-
"pytest-cov>=4.0.0",
34+
"pytest>=7.0.0",
35+
"pytest-cov>=4.0.0",
3636
]
37-
toml = ["tomli>=2.0.0", "tomli-w>=1.0.0"]
38-
license = ["revenueholdings-license>=0.1.0"]
3937

4038
[project.urls]
4139
Homepage = "https://github.com/Coding-Dev-Tools/configdrift"
@@ -58,7 +56,7 @@ line-length = 120
5856

5957
[tool.ruff.lint]
6058
select = ["E", "F", "W", "I", "UP", "B", "SIM"]
61-
ignore = ["E501", "B008", "SIM108"]
59+
ignore = ["E501"]
6260

6361
[tool.ruff.lint.isort]
6462
known-first-party = ["*"]

src/configdrift/cli.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
"""ConfigDrift CLI entry point."""
22

3-
import typer
4-
from enum import Enum
53
from pathlib import Path
4+
from typing import Dict, Any, Optional
5+
from enum import Enum
6+
7+
import typer
68
from rich.console import Console
79
from rich.table import Table
8-
from typing import Any
910

1011
try:
1112
from revenueholdings_license import require_license
@@ -16,11 +17,13 @@ def require_license(product: str) -> None: # type: ignore[misc]
1617
pass
1718

1819
from configdrift import __version__
20+
from configdrift.loader import load_file
1921
from configdrift.diff import (
22+
ChangeType,
2023
Severity,
24+
diff_configs,
2125
diff_environments,
2226
)
23-
from configdrift.loader import load_file
2427

2528
app = typer.Typer(
2629
name="configdrift",
@@ -68,20 +71,20 @@ def check(
6871
console.print("[red]ERROR: Provide at least 2 config files to compare.[/red]")
6972
raise typer.Exit(code=1)
7073

71-
env_configs: dict[str, dict[str, Any]] = {}
74+
env_configs: Dict[str, Dict[str, Any]] = {}
7275
env_labels = []
7376

7477
if len(files) == 2:
7578
env_labels = [baseline, target]
7679
else:
7780
env_labels = [f"file_{i+1}" for i in range(len(files))]
7881

79-
for label, filepath in zip(env_labels, files, strict=False):
82+
for label, filepath in zip(env_labels, files):
8083
try:
8184
env_configs[label] = load_file(filepath)
8285
except Exception as e:
8386
console.print(f"[red]Error loading {filepath}: {e}[/red]")
84-
raise typer.Exit(code=1) from e
87+
raise typer.Exit(code=1)
8588

8689
baseline_env = env_labels[0]
8790
results = diff_environments(env_configs, baseline_env=baseline_env)
@@ -100,7 +103,7 @@ def check(
100103
raise typer.Exit(code=1)
101104

102105

103-
def _output_table(results: dict[str, Any], baseline_env: str):
106+
def _output_table(results: Dict[str, Any], baseline_env: str):
104107
for env_name, diff_result in results.items():
105108
if not diff_result.changes:
106109
continue
@@ -132,7 +135,7 @@ def _output_table(results: dict[str, Any], baseline_env: str):
132135
console.print()
133136

134137

135-
def _output_json(results: dict[str, Any]):
138+
def _output_json(results: Dict[str, Any]):
136139
import json
137140
output = {}
138141
for env_name, diff_result in results.items():
@@ -155,16 +158,16 @@ def _output_json(results: dict[str, Any]):
155158

156159
@app.command()
157160
def scan(
158-
dirs: list[str] | None = typer.Argument(None, help="Directories containing config files. Each dir is treated as an environment."),
161+
dirs: Optional[list[str]] = typer.Argument(None, help="Directories containing config files. Each dir is treated as an environment."),
159162
baseline: str = typer.Option("dev", "--baseline", "-b", help="Baseline directory name for comparison."),
160-
config: str | None = typer.Option(None, "--config", "-c", help="Path to .configdrift.yaml config file."),
163+
config: Optional[str] = typer.Option(None, "--config", "-c", help="Path to .configdrift.yaml config file."),
161164
output: OutputFormat = typer.Option(OutputFormat.TABLE, "--output", "-o", help="Output format."),
162165
):
163166
"""Scan directories of config files and compare environments."""
164167
if config:
165168
# Load config file for directory → env mapping (raw, not flattened)
166169
import yaml as _yaml
167-
with open(config, encoding="utf-8") as _f:
170+
with open(config, "r", encoding="utf-8") as _f:
168171
cfg_data = _yaml.safe_load(_f) or {}
169172
dir_mapping = cfg_data.get("environments", {})
170173
elif dirs:
@@ -181,7 +184,7 @@ def scan(
181184
console.print(f"[red]Baseline environment '{baseline}' not found.[/red]")
182185
raise typer.Exit(code=1)
183186

184-
env_configs: dict[str, dict[str, Any]] = {}
187+
env_configs: Dict[str, Dict[str, Any]] = {}
185188
for env_name, dir_path in dir_mapping.items():
186189
env_configs[env_name] = {}
187190
p = Path(dir_path)

0 commit comments

Comments
 (0)