Skip to content

Commit c44c251

Browse files
authored
Merge pull request #6 from SemTiOne/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2 parents 09d7dc4 + 3b2ba44 commit c44c251

14 files changed

Lines changed: 38 additions & 44 deletions

‎.pre-commit-config.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repos:
1616
- id: detect-private-key
1717

1818
- repo: https://github.com/astral-sh/ruff-pre-commit
19-
rev: v0.15.22
19+
rev: v0.16.4
2020
hooks:
2121
- id: ruff-check
2222
args: [--fix]
@@ -28,7 +28,7 @@ repos:
2828
- id: actionlint
2929

3030
- repo: https://github.com/zizmorcore/zizmor-pre-commit
31-
rev: v1.28.0
31+
rev: v1.29.0
3232
hooks:
3333
- id: zizmor
3434
args: [--no-progress]

‎src/env_auditor/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from importlib.metadata import version, PackageNotFoundError
3+
from importlib.metadata import PackageNotFoundError, version
44

55
try:
66
__version__: str = version("env-auditor")

‎src/env_auditor/cli.py‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import re
55
import sys
66
from pathlib import Path
7-
from typing import NoReturn, Optional
7+
from typing import NoReturn
88

99
from env_auditor import __version__
1010
from env_auditor.colors import supports_color
@@ -19,7 +19,6 @@
1919
from env_auditor.reporter import render_json, render_text
2020
from env_auditor.scanner import scan_directory
2121

22-
2322
# ──────────────────────────────────────────────────────────────────────────────
2423
# Argument parser
2524
# ──────────────────────────────────────────────────────────────────────────────
@@ -130,7 +129,7 @@ def _resolve_scan_root(raw_path: str) -> Path:
130129
Raises:
131130
SystemExit(2): If the path does not exist or is not a directory.
132131
"""
133-
resolved: Optional[Path] = None
132+
resolved: Path | None = None
134133
try:
135134
resolved = Path(raw_path).resolve()
136135
except (OSError, ValueError) as exc:
@@ -319,9 +318,7 @@ def _run_audit(
319318
# "Result: PASS" while the process still exited 1.
320319
effective_undoc = diff.undocumented - ignore_keys
321320
effective_stale = diff.stale - ignore_keys
322-
if effective_undoc or diff.required_missing:
323-
exit_code = 1
324-
elif cfg.strict and effective_stale:
321+
if effective_undoc or diff.required_missing or cfg.strict and effective_stale:
325322
exit_code = 1
326323
else:
327324
exit_code = 0
@@ -357,7 +354,7 @@ def _run_audit(
357354
# ──────────────────────────────────────────────────────────────────────────────
358355

359356

360-
def main(argv: Optional[list[str]] = None) -> None:
357+
def main(argv: list[str] | None = None) -> None:
361358
"""Parse arguments, run the audit, and exit with the appropriate code.
362359
363360
Exit codes:

‎src/env_auditor/config.py‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
import re
44
import sys
5-
from dataclasses import dataclass, field, replace as dataclass_replace
5+
from dataclasses import dataclass, field
6+
from dataclasses import replace as dataclass_replace
67
from pathlib import Path
7-
from typing import Any, Optional
8+
from typing import Any
89

910
# Config file is searched in this order within the scan root.
1011
CONFIG_FILENAMES = (".env-auditorrc", "env-auditor.toml", "pyproject.toml")
@@ -107,7 +108,7 @@ def load_config_from_file(path: Path) -> EnvAuditorConfig:
107108
return _dict_to_config(raw, path)
108109

109110

110-
def _read_config_raw(path: Path) -> tuple[Optional[dict[str, Any]], bool]:
111+
def _read_config_raw(path: Path) -> tuple[dict[str, Any] | None, bool]:
111112
"""Validate size, parse path as TOML, and return its env-auditor section.
112113
113114
Shared by :func:`load_config` (auto-discovery) and
@@ -155,7 +156,7 @@ def _read_config_raw(path: Path) -> tuple[Optional[dict[str, Any]], bool]:
155156
return raw, False
156157

157158

158-
def _parse_toml_file(path: Path, is_pyproject: bool) -> Optional[dict[str, Any]]:
159+
def _parse_toml_file(path: Path, is_pyproject: bool) -> dict[str, Any] | None:
159160
"""Parse *path* as TOML and return the env-auditor section, or None.
160161
161162
Uses stdlib ``tomllib`` (Python 3.11+) with ``tomli`` fallback,
@@ -250,9 +251,12 @@ def _minimal_toml_parse(path: Path) -> dict[str, Any]:
250251
elif value.startswith("["):
251252
# Use pre-compiled regex — not constructed from user input
252253
current_node[key] = _LIST_ITEMS_RE.findall(value)
253-
elif value.startswith('"') and value.endswith('"'):
254-
current_node[key] = value[1:-1]
255-
elif value.startswith("'") and value.endswith("'"):
254+
elif (
255+
value.startswith('"')
256+
and value.endswith('"')
257+
or value.startswith("'")
258+
and value.endswith("'")
259+
):
256260
current_node[key] = value[1:-1]
257261
else:
258262
current_node[key] = value
@@ -340,12 +344,12 @@ def _dict_to_config(raw: dict[str, Any], source: Path) -> EnvAuditorConfig:
340344
def merge_cli_into_config(
341345
cfg: EnvAuditorConfig,
342346
*,
343-
env_files: Optional[list[str]] = None,
344-
exclude_dirs: Optional[list[str]] = None,
345-
ignore_stale: Optional[bool] = None,
346-
ignore_missing: Optional[bool] = None,
347-
strict: Optional[bool] = None,
348-
output_format: Optional[str] = None,
347+
env_files: list[str] | None = None,
348+
exclude_dirs: list[str] | None = None,
349+
ignore_stale: bool | None = None,
350+
ignore_missing: bool | None = None,
351+
strict: bool | None = None,
352+
output_format: str | None = None,
349353
) -> EnvAuditorConfig:
350354
"""Apply CLI overrides onto *cfg*, returning a new merged config.
351355

‎src/env_auditor/parser.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import sys
55
from dataclasses import dataclass, field
66
from pathlib import Path
7-
from typing import Optional
87

98
# Pre-compiled constants — never constructed from user input.
109
_VALID_KEY_RE: re.Pattern[str] = re.compile(r"^[A-Za-z_][A-Za-z0-9_]*$")
@@ -37,7 +36,7 @@ def empty_keys(self) -> frozenset[str]:
3736
return frozenset(k for k, v in self.keys_with_values.items() if v == "")
3837

3938

40-
def parse_env_file(path: Path) -> Optional[ParsedEnvFile]:
39+
def parse_env_file(path: Path) -> ParsedEnvFile | None:
4140
"""Parse a dotenv-format file and return its keys.
4241
4342
Sensitive value protection: values are stored only to detect emptiness.

‎src/env_auditor/patterns.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from __future__ import annotations
22

33
import re
4+
from collections.abc import Sequence
45
from dataclasses import dataclass, field
5-
from typing import Optional, Sequence
66

77
# Env var name: uppercase, starts with letter, underscores/digits allowed
88
ENV_VAR_NAME = r"([A-Z][A-Z0-9_]*)"
@@ -20,7 +20,7 @@ class LanguagePattern:
2020
extensions: Sequence[str]
2121
static_patterns: Sequence[re.Pattern[str]]
2222
dynamic_patterns: Sequence[re.Pattern[str]] = field(default_factory=list)
23-
line_filter: Optional[re.Pattern[str]] = None
23+
line_filter: re.Pattern[str] | None = None
2424
"""If set, static_patterns/dynamic_patterns are only applied to lines that
2525
match this filter first. Used by Docker: the KEY= continuation pattern
2626
(which has no anchor of its own) must not fire on RUN/LABEL/CMD lines that

‎src/env_auditor/reporter.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
import json
4-
from typing import Any, Optional
4+
from typing import Any
55

66
from env_auditor.colors import get_colors
77
from env_auditor.differ import DiffResult
@@ -16,7 +16,7 @@ def render_text(
1616
use_color: bool = True,
1717
ignore_stale: bool = False,
1818
ignore_missing: bool = False,
19-
ignore_keys: Optional[set[str]] = None,
19+
ignore_keys: set[str] | None = None,
2020
) -> str:
2121
"""Render a human-readable audit report.
2222
@@ -124,7 +124,7 @@ def render_json(
124124
passed: bool,
125125
ignore_stale: bool = False,
126126
ignore_missing: bool = False,
127-
ignore_keys: Optional[set[str]] = None,
127+
ignore_keys: set[str] | None = None,
128128
) -> str:
129129
"""Render a machine-readable JSON audit report.
130130

‎src/env_auditor/scanner.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import sys
66
from dataclasses import dataclass, field
77
from pathlib import Path
8-
from typing import Optional
98

109
from env_auditor.patterns import (
1110
DOCKERFILE_PATTERN,
@@ -109,7 +108,7 @@ def sanitize_raw(text: str) -> str:
109108

110109
def scan_directory(
111110
root: Path,
112-
extra_exclude: Optional[list[Path]] = None,
111+
extra_exclude: list[Path] | None = None,
113112
) -> ScanResult:
114113
"""Walk *root* recursively and extract all env var references.
115114

‎tests/test_cli.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
from env_auditor.cli import main
1010

11-
1211
# ──────────────────────────────────────────────────────────────────────────────
1312
# Helpers
1413
# ──────────────────────────────────────────────────────────────────────────────

‎tests/test_colors.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
43
from env_auditor.colors import Colors, NoColors, get_colors, supports_color
54

65

0 commit comments

Comments
 (0)