Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
chore: linting & formatting
  • Loading branch information
nandgator committed Mar 28, 2025
commit ad2e2c5bb4e94ff5798b51a9b28a26fa64684ed0
3 changes: 2 additions & 1 deletion package/export/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def _gen_rst_docs(source: Path, refs_path: Path, only_web: bool = False, only_ma
with open(source / "docs/index.rst", "wt") as idx_f:
idx_f.write(
convert_file(source_file=source / "docs/index.md", format="md", to="rst").replace(
"\r\n", "\n" # remove carriage return in windows
"\r\n",
"\n", # remove carriage return in windows
)
+ "\n\n.. toctree::"
+ "\n :hidden:"
Expand Down
1 change: 1 addition & 0 deletions src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Validators."""
1 change: 0 additions & 1 deletion src/validators/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def domain(
return False

try:

service_record = r"_" if rfc_2782 else ""
trailing_dot = r"\.?$" if rfc_1034 else r"$"

Expand Down
2 changes: 1 addition & 1 deletion src/validators/i18n/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"fr_ssn",
"ind_aadhar",
"ind_pan",
"ru_inn"
"ru_inn",
)
4 changes: 1 addition & 3 deletions src/validators/i18n/fi.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ def _ssn_pattern(ssn_check_marks: str):
(\d{{2}}))
[ABCDEFYXWVU+-]
(?P<serial>(\d{{3}}))
(?P<checksum>[{check_marks}])$""".format(
check_marks=ssn_check_marks
),
(?P<checksum>[{check_marks}])$""".format(check_marks=ssn_check_marks),
re.VERBOSE,
)

Expand Down
15 changes: 12 additions & 3 deletions src/validators/i18n/ru.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,25 @@ def ru_inn(value: str):
if len(digits) == 10:
weight_coefs = [2, 4, 10, 3, 5, 9, 4, 6, 8, 0]
control_number = sum([d * w for d, w in zip(digits, weight_coefs)]) % 11
return (control_number % 10) == digits[-1] if control_number > 9 else control_number == digits[-1]
return (
(control_number % 10) == digits[-1]
if control_number > 9
else control_number == digits[-1]
)
# person
elif len(digits) == 12:
weight_coefs1 = [7, 2, 4, 10, 3, 5, 9, 4, 6, 8, 0, 0]
control_number1 = sum([d * w for d, w in zip(digits, weight_coefs1)]) % 11
weight_coefs2 = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8, 0]
control_number2 = sum([d * w for d, w in zip(digits, weight_coefs2)]) % 11
print(control_number1, control_number2, value)
return ((control_number1 % 10) == digits[-2] if control_number1 > 9 else control_number1 == digits[-2] and
(control_number2 % 10) == digits[-1] if control_number2 > 9 else control_number2 == digits[-1])
return (
(control_number1 % 10) == digits[-2]
if control_number1 > 9
else control_number1 == digits[-2] and (control_number2 % 10) == digits[-1]
if control_number2 > 9
else control_number2 == digits[-1]
)
else:
return False
except ValueError:
Expand Down
18 changes: 14 additions & 4 deletions src/validators/uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,20 @@ def uri(value: str, /):
# url
if any(
# fmt: off
value.startswith(item) for item in {
"ftp", "ftps", "git", "http", "https",
"irc", "rtmp", "rtmps", "rtsp", "sftp",
"ssh", "telnet",
value.startswith(item)
for item in {
"ftp",
"ftps",
"git",
"http",
"https",
"irc",
"rtmp",
"rtmps",
"rtsp",
"sftp",
"ssh",
"telnet",
}
# fmt: on
):
Expand Down
15 changes: 12 additions & 3 deletions src/validators/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,18 @@ def _validate_scheme(value: str):
value
# fmt: off
in {
"ftp", "ftps", "git", "http", "https",
"irc", "rtmp", "rtmps", "rtsp", "sftp",
"ssh", "telnet",
"ftp",
"ftps",
"git",
"http",
"https",
"irc",
"rtmp",
"rtmps",
"rtsp",
"sftp",
"ssh",
"telnet",
}
# fmt: on
if value
Expand Down
4 changes: 2 additions & 2 deletions tests/i18n/test_ru.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],
)
def test_returns_true_on_valid_ru_inn(value: str):
"""Test returns true on valid russian individual tax number"""
"""Test returns true on valid russian individual tax number."""
assert ru_inn(value)


Expand All @@ -44,5 +44,5 @@ def test_returns_true_on_valid_ru_inn(value: str):
],
)
def test_returns_false_on_valid_ru_inn(value: str):
"""Test returns true on valid russian individual tax number"""
"""Test returns true on valid russian individual tax number."""
assert isinstance(ru_inn(value), ValidationError)
2 changes: 1 addition & 1 deletion tests/test_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def test_returns_true_on_valid_private_url(value: str, private: Optional[bool]):
":// should fail",
"http://foo.bar/foo(bar)baz quux",
"http://-error-.invalid/",
"http://www.\uFFFD.ch",
"http://www.\ufffd.ch",
"http://-a.b.co",
"http://a.b-.co",
"http://1.1.1.1.1",
Expand Down
Loading