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
5 changes: 3 additions & 2 deletions src/pact/generate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ def regex(regex: builtins.str) -> Generator:
return GenericGenerator("Regex", {"regex": regex})


_UUID_FORMATS = {
_UUID_FORMAT_NAMES = Literal["simple", "lowercase", "uppercase", "urn"]
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _UUID_FORMAT_NAMES type is duplicated across both files. Consider defining it in a shared module to maintain a single source of truth and prevent inconsistencies.

Copilot uses AI. Check for mistakes.
_UUID_FORMATS: dict[_UUID_FORMAT_NAMES, builtins.str] = {
"simple": "simple",
"lowercase": "lower-case-hyphenated",
"uppercase": "upper-case-hyphenated",
Expand All @@ -254,7 +255,7 @@ def regex(regex: builtins.str) -> Generator:


def uuid(
format: Literal["simple", "lowercase", "uppercase", "urn"] = "lowercase",
format: _UUID_FORMAT_NAMES = "lowercase",
) -> Generator:
"""
Create a UUID generator.
Expand Down
5 changes: 3 additions & 2 deletions src/pact/match/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,8 @@ def regex(
)


_UUID_FORMATS = {
_UUID_FORMAT_NAMES = Literal["simple", "lowercase", "uppercase", "urn"]
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _UUID_FORMAT_NAMES type is duplicated across both files. Consider defining it in a shared module to maintain a single source of truth and prevent inconsistencies.

Suggested change
_UUID_FORMAT_NAMES = Literal["simple", "lowercase", "uppercase", "urn"]
from pact.types import _UUID_FORMAT_NAMES

Copilot uses AI. Check for mistakes.
_UUID_FORMATS: dict[_UUID_FORMAT_NAMES, builtins.str] = {
"simple": r"[0-9a-fA-F]{32}",
"lowercase": r"[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}",
"uppercase": r"[0-9A-F]{8}(-[0-9A-F]{4}){3}-[0-9A-F]{12}",
Expand All @@ -454,7 +455,7 @@ def uuid(
value: builtins.str | Unset = UNSET,
/,
*,
format: Literal["uppercase", "lowercase", "urn", "simple"] | None = None,
format: _UUID_FORMAT_NAMES | None = None,
) -> Matcher[builtins.str]:
"""
Match a UUID value.
Expand Down
Loading