Skip to content

Commit a58300e

Browse files
author
Rhea Lakhotia
committed
Fix lint errors using Ruff
1 parent 8c51265 commit a58300e

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

pydantic_extra_types/domain.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
class DomainStr(str):
1515
"""A string subclass with custom validation for domain string format."""
1616

17-
_domain_re_pattern = (r'(?=^.{1,253}$)'r'(^((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\.)+'r'([a-zA-Z]{2,63}|xn--[a-zA-Z0-9]{2,59})$)')
17+
_domain_re_pattern = (
18+
r'(?=^.{1,253}$)' r'(^((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\.)+' r'([a-zA-Z]{2,63}|xn--[a-zA-Z0-9]{2,59})$)'
19+
)
1820

1921
@classmethod
2022
def validate(cls, __input_value: Any, _: Any) -> str:

tests/test_domain.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,22 @@ def test_invalid_domain_types(domain: Any):
7777
with pytest.raises(ValidationError, match='Value must be a string'):
7878
MyModel(domain=domain)
7979

80+
8081
def test_domainstr_with_punycode():
8182
class Model(BaseModel):
8283
domain: DomainStr
8384

84-
valid = "xn--7-7sbirhro.xn--80ahmohdapg.xn--80asehdb"
85+
valid = 'xn--7-7sbirhro.xn--80ahmohdapg.xn--80asehdb'
8586
model = Model(domain=valid)
8687
assert model.domain == valid
8788

89+
8890
def test_domainstr_invalid():
8991
class Model(BaseModel):
9092
domain: DomainStr
9193

9294
try:
93-
Model(domain="invalid_domain")
94-
assert False, "Expected ValidationError"
95+
Model(domain='invalid_domain')
96+
assert False, 'Expected ValidationError'
9597
except ValidationError:
96-
pass
98+
pass

0 commit comments

Comments
 (0)