Skip to content

Commit be9dee4

Browse files
committed
rename fstring validator to validate_fstring
1 parent a598171 commit be9dee4

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

sde_collections/models/delta_patterns.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
from django.db import models
77

88
from ..utils.title_resolver import (
9-
is_valid_fstring,
109
is_valid_xpath,
1110
parse_title,
1211
resolve_title,
12+
validate_fstring,
1313
)
1414
from .collection_choice_fields import Divisions, DocumentTypes
1515

@@ -398,7 +398,7 @@ def validate_title_pattern(title_pattern_string: str) -> None:
398398
raise ValidationError(f"Invalid xpath: {element_value}")
399399
elif element_type == "brace":
400400
try:
401-
is_valid_fstring(element_value)
401+
validate_fstring(element_value)
402402
except ValueError as e:
403403
raise ValidationError(str(e))
404404

sde_collections/models/pattern.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
from django.db import models
66

77
from ..utils.title_resolver import (
8-
is_valid_fstring,
98
is_valid_xpath,
109
parse_title,
1110
resolve_title,
11+
validate_fstring,
1212
)
1313
from .collection_choice_fields import Divisions, DocumentTypes
1414

@@ -146,7 +146,7 @@ def validate_title_pattern(title_pattern_string):
146146
raise ValidationError(f"'xpath:{element_value}' is not a valid xpath.") # noqa: E231
147147
elif element_type == "brace":
148148
try:
149-
is_valid_fstring(element_value)
149+
validate_fstring(element_value)
150150
except ValueError as e:
151151
raise ValidationError(str(e))
152152

sde_collections/utils/title_resolver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def is_valid_xpath(xpath: str) -> bool:
1717
return False
1818

1919

20-
def is_valid_fstring(pattern: str) -> bool:
20+
def validate_fstring(pattern: str) -> bool:
2121
context = {
2222
"url": "",
2323
"title": "",
@@ -53,7 +53,7 @@ def resolve_brace(pattern: str, context: dict[str, Any]) -> str:
5353
"""Safely interpolates the variables in an f-string pattern using the provided context."""
5454
parsed = ast.parse(f"f'''{pattern}'''", mode="eval")
5555

56-
is_valid_fstring(pattern) # Refactor this
56+
validate_fstring(pattern)
5757

5858
compiled = compile(parsed, "<string>", "eval")
5959
return str(eval(compiled, {}, context))

0 commit comments

Comments
 (0)