Skip to content

Commit d9578c2

Browse files
committed
chore: replaed kwargs with param names in create expectation functions
1 parent a2d6a60 commit d9578c2

File tree

10 files changed

+239
-244
lines changed

10 files changed

+239
-244
lines changed

dataframe_expectations/expectations/aggregation_expectations/__init__.py

Whitespace-only changes.

dataframe_expectations/expectations/aggregation_expectations/any_value_expectations.py

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ def __init__(self, min_rows: int):
3838
"""
3939
Initialize the minimum rows expectation.
4040
41-
Args:
42-
min_rows (int): Minimum number of rows required (inclusive).
41+
:param min_rows: Minimum number of rows required (inclusive).
4342
"""
4443
if min_rows < 0:
4544
raise ValueError(f"min_rows must be non-negative, got {min_rows}")
@@ -124,8 +123,7 @@ def __init__(self, max_rows: int):
124123
"""
125124
Initialize the maximum rows expectation.
126125
127-
Args:
128-
max_rows (int): Maximum number of rows allowed (inclusive).
126+
:param max_rows: Maximum number of rows allowed (inclusive).
129127
"""
130128
if max_rows < 0:
131129
raise ValueError(f"max_rows must be non-negative, got {max_rows}")
@@ -214,9 +212,8 @@ def __init__(self, column_name: str, max_percentage: float):
214212
"""
215213
Initialize the maximum null percentage expectation.
216214
217-
Args:
218-
column_name (str): Name of the column to check for null percentage.
219-
max_percentage (float): Maximum percentage of null values allowed (0.0-100.0).
215+
:param column_name: Name of the column to check for null percentage.
216+
:param max_percentage: Maximum percentage of null values allowed (0.0-100.0).
220217
"""
221218
if not 0 <= max_percentage <= 100:
222219
raise ValueError(f"max_percentage must be between 0.0 and 100.0, got {max_percentage}")
@@ -332,9 +329,8 @@ def __init__(self, column_name: str, max_count: int):
332329
"""
333330
Initialize the maximum null count expectation.
334331
335-
Args:
336-
column_name (str): Name of the column to check for null count.
337-
max_count (int): Maximum number of null values allowed.
332+
:param column_name: Name of the column to check for null count.
333+
:param max_count: Maximum number of null values allowed.
338334
"""
339335
if max_count < 0:
340336
raise ValueError(f"max_count must be non-negative, got {max_count}")
@@ -426,17 +422,14 @@ def aggregate_and_validate_pyspark(
426422
},
427423
)
428424
@requires_params("min_rows", types={"min_rows": int})
429-
def create_expectation_min_rows(**kwargs) -> ExpectationMinRows:
425+
def create_expectation_min_rows(min_rows: int) -> ExpectationMinRows:
430426
"""
431427
Create an ExpectMinRows instance.
432428
433-
Args:
434-
min_rows (int): Minimum number of rows required.
435-
436-
Returns:
437-
ExpectationMinRows: A configured expectation instance.
429+
:param min_rows: Minimum number of rows required.
430+
:return: A configured expectation instance.
438431
"""
439-
return ExpectationMinRows(min_rows=kwargs["min_rows"])
432+
return ExpectationMinRows(min_rows=min_rows)
440433

441434

442435
@register_expectation(
@@ -449,17 +442,14 @@ def create_expectation_min_rows(**kwargs) -> ExpectationMinRows:
449442
},
450443
)
451444
@requires_params("max_rows", types={"max_rows": int})
452-
def create_expectation_max_rows(**kwargs) -> ExpectationMaxRows:
445+
def create_expectation_max_rows(max_rows: int) -> ExpectationMaxRows:
453446
"""
454447
Create an ExpectationMaxRows instance.
455448
456-
Args:
457-
max_rows (int): Maximum number of rows allowed.
458-
459-
Returns:
460-
ExpectationMaxRows: A configured expectation instance.
449+
:param max_rows: Maximum number of rows allowed.
450+
:return: A configured expectation instance.
461451
"""
462-
return ExpectationMaxRows(max_rows=kwargs["max_rows"])
452+
return ExpectationMaxRows(max_rows=max_rows)
463453

464454

465455
@register_expectation(
@@ -477,20 +467,19 @@ def create_expectation_max_rows(**kwargs) -> ExpectationMaxRows:
477467
"max_percentage",
478468
types={"column_name": str, "max_percentage": (int, float)},
479469
)
480-
def create_expectation_max_null_percentage(**kwargs) -> ExpectationMaxNullPercentage:
470+
def create_expectation_max_null_percentage(
471+
column_name: str, max_percentage: float
472+
) -> ExpectationMaxNullPercentage:
481473
"""
482474
Create an ExpectationMaxNullPercentage instance.
483475
484-
Args:
485-
column_name (str): Name of the column to check for null percentage.
486-
max_percentage (float): Maximum percentage of null values allowed (0.0-100.0).
487-
488-
Returns:
489-
ExpectationMaxNullPercentage: A configured expectation instance.
476+
:param column_name: Name of the column to check for null percentage.
477+
:param max_percentage: Maximum percentage of null values allowed (0.0-100.0).
478+
:return: A configured expectation instance.
490479
"""
491480
return ExpectationMaxNullPercentage(
492-
column_name=kwargs["column_name"],
493-
max_percentage=kwargs["max_percentage"],
481+
column_name=column_name,
482+
max_percentage=max_percentage,
494483
)
495484

496485

@@ -509,18 +498,15 @@ def create_expectation_max_null_percentage(**kwargs) -> ExpectationMaxNullPercen
509498
"max_count",
510499
types={"column_name": str, "max_count": int},
511500
)
512-
def create_expectation_max_null_count(**kwargs) -> ExpectationMaxNullCount:
501+
def create_expectation_max_null_count(column_name: str, max_count: int) -> ExpectationMaxNullCount:
513502
"""
514503
Create an ExpectationMaxNullCount instance.
515504
516-
Args:
517-
column_name (str): Name of the column to check for null count.
518-
max_count (int): Maximum number of null values allowed.
519-
520-
Returns:
521-
ExpectationMaxNullCount: A configured expectation instance.
505+
:param column_name: Name of the column to check for null count.
506+
:param max_count: Maximum number of null values allowed.
507+
:return: A configured expectation instance.
522508
"""
523509
return ExpectationMaxNullCount(
524-
column_name=kwargs["column_name"],
525-
max_count=kwargs["max_count"],
510+
column_name=column_name,
511+
max_count=max_count,
526512
)

dataframe_expectations/expectations/aggregation_expectations/numerical_expectations.py

Lines changed: 61 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,11 @@ def __init__(
5353
"""
5454
Initialize the column quantile between expectation.
5555
56-
Args:
57-
column_name (str): Name of the column to check.
58-
quantile (float): Quantile to compute (0.0 to 1.0, where 0.0=min, 0.5=median, 1.0=max).
59-
min_value (Union[int, float]): Minimum allowed value for the column quantile (inclusive).
60-
max_value (Union[int, float]): Maximum allowed value for the column quantile (inclusive).
61-
62-
Raises:
63-
ValueError: If quantile is not between 0.0 and 1.0.
56+
:param column_name: Name of the column to check.
57+
:param quantile: Quantile to compute (0.0 to 1.0, where 0.0=min, 0.5=median, 1.0=max).
58+
:param min_value: Minimum allowed value for the column quantile (inclusive).
59+
:param max_value: Maximum allowed value for the column quantile (inclusive).
60+
:raises ValueError: If quantile is not between 0.0 and 1.0.
6461
"""
6562
if not (0.0 <= quantile <= 1.0):
6663
raise ValueError(f"Quantile must be between 0.0 and 1.0, got {quantile}")
@@ -226,10 +223,9 @@ def __init__(
226223
"""
227224
Initialize the column mean between expectation.
228225
229-
Args:
230-
column_name (str): Name of the column to check.
231-
min_value (Union[int, float]): Minimum allowed value for the column mean (inclusive).
232-
max_value (Union[int, float]): Maximum allowed value for the column mean (inclusive).
226+
:param column_name: Name of the column to check.
227+
:param min_value: Minimum allowed value for the column mean (inclusive).
228+
:param max_value: Maximum allowed value for the column mean (inclusive).
233229
"""
234230
description = f"column '{column_name}' mean value between {min_value} and {max_value}"
235231

@@ -345,25 +341,25 @@ def aggregate_and_validate_pyspark(
345341
},
346342
)
347343
def create_expectation_column_quantile_between(
348-
**kwargs,
344+
column_name: str,
345+
quantile: float,
346+
min_value: Union[int, float],
347+
max_value: Union[int, float],
349348
) -> ExpectationColumnQuantileBetween:
350349
"""
351350
Create an ExpectationColumnQuantileBetween instance.
352351
353-
Args:
354-
column_name (str): Name of the column to check.
355-
quantile (float): Quantile to compute (0.0 to 1.0).
356-
min_value (Union[int, float]): Minimum allowed value for the column quantile.
357-
max_value (Union[int, float]): Maximum allowed value for the column quantile.
358-
359-
Returns:
360-
ExpectationColumnQuantileBetween: A configured expectation instance.
352+
:param column_name: Name of the column to check.
353+
:param quantile: Quantile to compute (0.0 to 1.0).
354+
:param min_value: Minimum allowed value for the column quantile.
355+
:param max_value: Maximum allowed value for the column quantile.
356+
:return: A configured expectation instance.
361357
"""
362358
return ExpectationColumnQuantileBetween(
363-
column_name=kwargs["column_name"],
364-
quantile=kwargs["quantile"],
365-
min_value=kwargs["min_value"],
366-
max_value=kwargs["max_value"],
359+
column_name=column_name,
360+
quantile=quantile,
361+
min_value=min_value,
362+
max_value=max_value,
367363
)
368364

369365

@@ -386,24 +382,23 @@ def create_expectation_column_quantile_between(
386382
types={"column_name": str, "min_value": (int, float), "max_value": (int, float)},
387383
)
388384
def create_expectation_column_max_to_be_between(
389-
**kwargs,
385+
column_name: str,
386+
min_value: Union[int, float],
387+
max_value: Union[int, float],
390388
) -> ExpectationColumnQuantileBetween:
391389
"""
392390
Create an ExpectationColumnQuantileBetween instance for maximum values (quantile=1.0).
393391
394-
Args:
395-
column_name (str): Name of the column to check.
396-
min_value (Union[int, float]): Minimum allowed value for the column maximum.
397-
max_value (Union[int, float]): Maximum allowed value for the column maximum.
398-
399-
Returns:
400-
ExpectationColumnQuantileBetween: A configured expectation instance for maximum values.
392+
:param column_name: Name of the column to check.
393+
:param min_value: Minimum allowed value for the column maximum.
394+
:param max_value: Maximum allowed value for the column maximum.
395+
:return: A configured expectation instance for maximum values.
401396
"""
402397
return ExpectationColumnQuantileBetween(
403-
column_name=kwargs["column_name"],
398+
column_name=column_name,
404399
quantile=1.0,
405-
min_value=kwargs["min_value"],
406-
max_value=kwargs["max_value"],
400+
min_value=min_value,
401+
max_value=max_value,
407402
)
408403

409404

@@ -425,24 +420,23 @@ def create_expectation_column_max_to_be_between(
425420
types={"column_name": str, "min_value": (int, float), "max_value": (int, float)},
426421
)
427422
def create_expectation_column_min_to_be_between(
428-
**kwargs,
423+
column_name: str,
424+
min_value: Union[int, float],
425+
max_value: Union[int, float],
429426
) -> ExpectationColumnQuantileBetween:
430427
"""
431428
Create an ExpectationColumnQuantileBetween instance for minimum values (quantile=0.0).
432429
433-
Args:
434-
column_name (str): Name of the column to check.
435-
min_value (Union[int, float]): Minimum allowed value for the column minimum.
436-
max_value (Union[int, float]): Maximum allowed value for the column minimum.
437-
438-
Returns:
439-
ExpectationColumnQuantileBetween: A configured expectation instance for minimum values.
430+
:param column_name: Name of the column to check.
431+
:param min_value: Minimum allowed value for the column minimum.
432+
:param max_value: Maximum allowed value for the column minimum.
433+
:return: A configured expectation instance for minimum values.
440434
"""
441435
return ExpectationColumnQuantileBetween(
442-
column_name=kwargs["column_name"],
436+
column_name=column_name,
443437
quantile=0.0,
444-
min_value=kwargs["min_value"],
445-
max_value=kwargs["max_value"],
438+
min_value=min_value,
439+
max_value=max_value,
446440
)
447441

448442

@@ -464,25 +458,24 @@ def create_expectation_column_min_to_be_between(
464458
types={"column_name": str, "min_value": (int, float), "max_value": (int, float)},
465459
)
466460
def create_expectation_column_mean_to_be_between(
467-
**kwargs,
461+
column_name: str,
462+
min_value: Union[int, float],
463+
max_value: Union[int, float],
468464
) -> ExpectationColumnMeanBetween:
469465
"""
470466
Create a custom ExpectationColumnMeanBetween instance for mean values.
471467
Note: This uses a separate implementation since mean is not a quantile.
472468
473-
Args:
474-
column_name (str): Name of the column to check.
475-
min_value (Union[int, float]): Minimum allowed value for the column mean.
476-
max_value (Union[int, float]): Maximum allowed value for the column mean.
477-
478-
Returns:
479-
ExpectationColumnMeanBetween: A configured expectation instance for mean values.
469+
:param column_name: Name of the column to check.
470+
:param min_value: Minimum allowed value for the column mean.
471+
:param max_value: Maximum allowed value for the column mean.
472+
:return: A configured expectation instance for mean values.
480473
"""
481474
# For mean, we need a separate class since it's not a quantile
482475
return ExpectationColumnMeanBetween(
483-
column_name=kwargs["column_name"],
484-
min_value=kwargs["min_value"],
485-
max_value=kwargs["max_value"],
476+
column_name=column_name,
477+
min_value=min_value,
478+
max_value=max_value,
486479
)
487480

488481

@@ -504,22 +497,21 @@ def create_expectation_column_mean_to_be_between(
504497
types={"column_name": str, "min_value": (int, float), "max_value": (int, float)},
505498
)
506499
def create_expectation_column_median_to_be_between(
507-
**kwargs,
500+
column_name: str,
501+
min_value: Union[int, float],
502+
max_value: Union[int, float],
508503
) -> ExpectationColumnQuantileBetween:
509504
"""
510505
Create an ExpectationColumnQuantileBetween instance for median values (quantile=0.5).
511506
512-
Args:
513-
column_name (str): Name of the column to check.
514-
min_value (Union[int, float]): Minimum allowed value for the column median.
515-
max_value (Union[int, float]): Maximum allowed value for the column median.
516-
517-
Returns:
518-
ExpectationColumnQuantileBetween: A configured expectation instance for median values.
507+
:param column_name: Name of the column to check.
508+
:param min_value: Minimum allowed value for the column median.
509+
:param max_value: Maximum allowed value for the column median.
510+
:return: A configured expectation instance for median values.
519511
"""
520512
return ExpectationColumnQuantileBetween(
521-
column_name=kwargs["column_name"],
513+
column_name=column_name,
522514
quantile=0.5,
523-
min_value=kwargs["min_value"],
524-
max_value=kwargs["max_value"],
515+
min_value=min_value,
516+
max_value=max_value,
525517
)

0 commit comments

Comments
 (0)