Skip to content

Commit adec96e

Browse files
committed
chore: qa fixes
1 parent 250ea41 commit adec96e

2 files changed

Lines changed: 26 additions & 12 deletions

File tree

pyatlan/model/assets/core/alpha__d_q_rule.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ def updater(
289289
retrieved_column = search_result.alpha_dq_rule_base_column # type: ignore[attr-defined]
290290
retrieved_alert_priority = search_result.alpha_dq_rule_alert_priority # type: ignore[attr-defined]
291291
retrieved_row_scope_filtering_enabled = (
292-
search_result.alpha_dq_rule_row_scope_filtering_enabled
293-
) # type: ignore[attr-defined]
292+
search_result.alpha_dq_rule_row_scope_filtering_enabled # type: ignore[attr-defined]
293+
)
294294
retrieved_description = search_result.user_description
295295
retrieved_asset = search_result.alpha_dq_rule_base_dataset # type: ignore[attr-defined]
296296
retrieved_template_rule_name = search_result.alpha_dq_rule_template_name # type: ignore[attr-defined]
@@ -332,12 +332,18 @@ def updater(
332332
)
333333
)
334334

335+
final_compare_operator = (
336+
validated_threshold_operator
337+
or threshold_compare_operator
338+
or retrieved_threshold_compare_operator
339+
)
340+
335341
config_arguments_raw = alpha_DQRule.Attributes._generate_config_arguments_raw(
336342
is_alert_enabled=True,
337343
custom_sql=custom_sql or retrieved_custom_sql,
338344
display_name=rule_name or retrieved_rule_name,
339345
dimension=dimension or retrieved_dimension,
340-
compare_operator=validated_threshold_operator,
346+
compare_operator=final_compare_operator,
341347
threshold_value=threshold_value or retrieved_threshold_value,
342348
threshold_unit=threshold_unit or retrieved_threshold_unit,
343349
column=retrieved_column,
@@ -351,7 +357,7 @@ def updater(
351357
name="",
352358
alpha_dq_rule_config_arguments=alpha_DQRuleConfigArguments(
353359
alpha_dq_rule_threshold_object=alpha_DQRuleThresholdObject(
354-
alpha_dq_rule_threshold_compare_operator=validated_threshold_operator,
360+
alpha_dq_rule_threshold_compare_operator=final_compare_operator,
355361
alpha_dq_rule_threshold_value=threshold_value
356362
or retrieved_threshold_value,
357363
alpha_dq_rule_threshold_unit=threshold_unit
@@ -1085,7 +1091,9 @@ class Attributes(DataQuality.Attributes):
10851091

10861092
@staticmethod
10871093
def _get_template_config_value(
1088-
config_value: str, property_name: str = None, value_key: str = "default"
1094+
config_value: str,
1095+
property_name: Optional[str] = None,
1096+
value_key: str = "default",
10891097
):
10901098
if not config_value:
10911099
return None
@@ -1112,9 +1120,9 @@ def _validate_template_features(
11121120
alpha_DQRuleThresholdCompareOperator
11131121
] = None,
11141122
asset: Optional[Asset] = None,
1115-
) -> alpha_DQRuleThresholdCompareOperator:
1123+
) -> Optional[alpha_DQRuleThresholdCompareOperator]:
11161124
if not template_config or not template_config.get("config"):
1117-
return
1125+
return None
11181126

11191127
config = template_config["config"]
11201128

@@ -1147,7 +1155,7 @@ def _validate_template_features(
11471155
if rule_conditions:
11481156
allowed_rule_conditions = (
11491157
alpha_DQRule.Attributes._get_template_config_value(
1150-
config.alpha_dq_rule_template_config_rule_conditions,
1158+
config.alpha_dq_rule_template_config_rule_conditions or "",
11511159
None,
11521160
"enum",
11531161
)

pyatlan/model/dq_rule_conditions.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,19 @@ def __init__(
4646
validate_required_fields(
4747
["min_value", "max_value"], [self.min_value, self.max_value]
4848
)
49-
if self.min_value < 0 or self.max_value < 0:
49+
if (self.min_value is not None and self.min_value < 0) or (
50+
self.max_value is not None and self.max_value < 0
51+
):
5052
raise ErrorCode.INVALID_PARAMETER_VALUE.exception_with_parameters(
5153
f"min_value={self.min_value}, max_value={self.max_value}",
5254
"min_value, max_value",
5355
"non-negative integers",
5456
)
55-
if self.min_value > self.max_value:
57+
if (
58+
self.min_value is not None
59+
and self.max_value is not None
60+
and self.min_value > self.max_value
61+
):
5662
raise ErrorCode.INVALID_PARAMETER_VALUE.exception_with_parameters(
5763
f"min_value={self.min_value}, max_value={self.max_value}",
5864
"min_value, max_value",
@@ -73,7 +79,7 @@ def __init__(
7379

7480
def to_dict(self) -> Dict[str, Any]:
7581
"""Convert the condition to a dictionary representation."""
76-
result = {"type": self.type.value}
82+
result: Dict[str, Any] = {"type": self.type.value}
7783

7884
if self.type == alpha_dqRuleTemplateConfigRuleConditions.STRING_LENGTH_BETWEEN:
7985
result["value"] = {"minValue": self.min_value, "maxValue": self.max_value}
@@ -86,7 +92,7 @@ def to_dict(self) -> Dict[str, Any]:
8692
class DQRuleConditionsBuilder:
8793
"""Builder for data quality rule conditions."""
8894

89-
def __init__(self):
95+
def __init__(self) -> None:
9096
self._conditions: List[DQCondition] = []
9197

9298
def add_condition(

0 commit comments

Comments
 (0)