Skip to content

Commit 6031d91

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 788d12c commit 6031d91

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

great_expectations/expectations/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,3 @@
6060
ExpectTableRowCountToEqualOtherTable,
6161
UnexpectedRowsExpectation,
6262
)
63-
64-

great_expectations/expectations/core/expect_column_values_to_be_valid_chinese_id_card.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ def _prescriptive_renderer(
5252
)
5353

5454
if params["mostly"] is not None and params["mostly"] < 1.0:
55-
params["mostly_pct"] = num_to_str(params["mostly"] * 100, precision=4, no_scientific=True)
55+
params["mostly_pct"] = num_to_str(
56+
params["mostly"] * 100, precision=4, no_scientific=True
57+
)
5658
template_str = "值必须为有效的中国身份证号,至少 $mostly_pct % 的时间满足。"
5759
else:
5860
template_str = "值必须为有效的中国身份证号。"
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
from great_expectations.expectations.expectation import ColumnMapExpectation
21
import re
32

3+
from great_expectations.expectations.expectation import ColumnMapExpectation
4+
5+
46
class ExpectColumnValuesToBeValidChineseIdCard(ColumnMapExpectation):
57
"""验证中国身份证号(15位/18位)"""
8+
69
map_metric = "column_values.valid_chinese_id_card"
710
success_keys = ("mostly",)
811

@@ -15,7 +18,6 @@ def validate_id(self, id_str: str) -> bool:
1518
if len(id_str) == 18:
1619
if not re.match(r"^\d{17}[\dXx]$", id_str):
1720
return False
18-
else:
19-
if not re.match(r"^\d{15}$", id_str):
20-
return False
21-
return True
21+
elif not re.match(r"^\d{15}$", id_str):
22+
return False
23+
return True

0 commit comments

Comments
 (0)