Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/guide/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The `name` is used in violation output and in `# pdl: ignore` comments. The opti

| Field | Required | Description |
|-------|----------|-------------|
| `name` | Yes | Unique identifier. Must match `[a-zA-Z0-9_-]+`. Shown in violation output and referenced in `# pdl: ignore` comments |
| `name` | Yes | Unique identifier. Must match `[a-zA-Z0-9_.-]+`. Shown in violation output and referenced in `# pdl: ignore` comments |
| `modules` | Yes | Module pattern to apply the rule to. Supports `*`, `**`, and `{name}` captures (see [Patterns](#patterns)) |
| `description` | No | Human-readable description shown in violation output |
| `allow` | No | Whitelist of allowed dependencies (see [Allow / Deny](#allow-deny)) |
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/config-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Complete reference for all configuration fields.

| Field | Type | Required | Default | Description |
|-------|------|----------|---------|-------------|
| `name` | str | Yes | — | Rule identifier, shown in violation output. Must match `[a-zA-Z0-9_-]+` |
| `name` | str | Yes | — | Rule identifier, shown in violation output. Must match `[a-zA-Z0-9_.-]+` |
| `modules` | str | Yes | — | Module pattern to apply the rule to. Supports `*`, `**`, and `{name}` captures |
| `description` | str | No | `null` | Human-readable description shown in violation output |
| `allow` | [DependencyFilter](#dependencyfilter) | No | `null` | Whitelist of allowed dependencies |
Expand Down
4 changes: 2 additions & 2 deletions python_dependency_linter/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _parse_allow_deny(data: dict | None) -> AllowDeny | None:
)


_RULE_NAME_PATTERN = re.compile(r"^[a-zA-Z0-9_-]+$")
_RULE_NAME_PATTERN = re.compile(r"^[a-zA-Z0-9_.\-]+$")


def _parse_rules(rules_data: list[dict]) -> list[Rule]:
Expand All @@ -49,7 +49,7 @@ def _parse_rules(rules_data: list[dict]) -> list[Rule]:
name = r["name"]
if not _RULE_NAME_PATTERN.match(name):
raise ValueError(
f"Invalid rule name '{name}'. Rule names must match [a-zA-Z0-9_-]+"
f"Invalid rule name '{name}'. Rule names must match [a-zA-Z0-9_.-]+"
)
rules.append(
Rule(
Expand Down
6 changes: 5 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,15 @@ def test_valid_rule_names(tmp_path):
modules: src.*
- name: rule1
modules: src.*
- name: shared.domain
modules: src.*
- name: context.adapters.inbound
modules: src.*
"""
config_file = tmp_path / "config.yaml"
config_file.write_text(config_content)
config = load_config(config_file)
assert len(config.rules) == 3
assert len(config.rules) == 5


def test_invalid_rule_name_with_space(tmp_path):
Expand Down
Loading