|
1 | 1 | import re |
2 | | -from enum import Enum |
3 | 2 | from typing import Any, Callable, Dict, Optional |
4 | 3 |
|
5 | | -from pydantic import BaseModel, ConfigDict, Field |
6 | | - |
7 | 4 | from dataframe_expectations.core.expectation import DataFrameExpectation |
| 5 | +from dataframe_expectations.core.types import ( |
| 6 | + ExpectationCategory, |
| 7 | + ExpectationMetadata, |
| 8 | + ExpectationSubcategory, |
| 9 | +) |
8 | 10 | from dataframe_expectations.logging_utils import setup_logger |
9 | 11 |
|
10 | 12 | logger = setup_logger(__name__) |
11 | 13 |
|
12 | 14 |
|
13 | | -class ExpectationCategory(str, Enum): |
14 | | - """Categories for expectations.""" |
15 | | - |
16 | | - COLUMN_EXPECTATIONS = "Column Expectations" |
17 | | - COLUMN_AGGREGATION_EXPECTATIONS = "Column Aggregation Expectations" |
18 | | - DATAFRAME_AGGREGATION_EXPECTATIONS = "DataFrame Aggregation Expectations" |
19 | | - |
20 | | - |
21 | | -class ExpectationSubcategory(str, Enum): |
22 | | - """Subcategory of expectations.""" |
23 | | - |
24 | | - ANY_VALUE = "Any Value" |
25 | | - NUMERICAL = "Numerical" |
26 | | - STRING = "String" |
27 | | - UNIQUE = "Unique" |
28 | | - |
29 | | - |
30 | | -class ExpectationMetadata(BaseModel): |
31 | | - """Metadata for a registered expectation.""" |
32 | | - |
33 | | - suite_method_name: str = Field( |
34 | | - ..., description="Method name in ExpectationsSuite (e.g., 'expect_value_greater_than')" |
35 | | - ) |
36 | | - pydoc: str = Field(..., description="Human-readable description of the expectation") |
37 | | - category: ExpectationCategory = Field(..., description="Category (e.g., 'Column Expectations')") |
38 | | - subcategory: ExpectationSubcategory = Field( |
39 | | - ..., description="Subcategory (e.g., 'Numerical', 'String')" |
40 | | - ) |
41 | | - params_doc: Dict[str, str] = Field(..., description="Documentation for each parameter") |
42 | | - params: list = Field(default_factory=list, description="List of required parameter names") |
43 | | - param_types: Dict[str, Any] = Field( |
44 | | - default_factory=dict, description="Type hints for parameters" |
45 | | - ) |
46 | | - factory_func_name: str = Field(..., description="Name of the factory function") |
47 | | - expectation_name: str = Field(..., description="Name of the expectation class") |
48 | | - |
49 | | - model_config = ConfigDict(frozen=True) # Make model immutable |
50 | | - |
51 | | - |
52 | 15 | class DataFrameExpectationRegistry: |
53 | 16 | """Registry for dataframe expectations.""" |
54 | 17 |
|
|
0 commit comments