99from dataclasses import field
1010from datetime import timedelta
1111from pathlib import Path
12+ from typing import Any
1213
1314import networkx as nx
1415import polars as pl
2829
2930@dataclasses .dataclass
3031class PlainPredicateConfig :
31- code : str | dict
32+ code : str | dict [ str , Any ]
3233 value_min : float | None = None
3334 value_max : float | None = None
3435 value_min_inclusive : bool | None = None
@@ -294,7 +295,7 @@ class DerivedPredicateConfig:
294295 expr : str
295296 static : bool = False
296297
297- def __post_init__ (self ):
298+ def __post_init__ (self ) -> None :
298299 if not self .expr :
299300 raise ValueError ("Derived predicates must have a non-empty expression field." )
300301
@@ -652,7 +653,7 @@ class WindowConfig:
652653 index_timestamp : str | None = None
653654
654655 @classmethod
655- def _check_reference (cls , reference : str ):
656+ def _check_reference (cls , reference : str ) -> None :
656657 """Checks to ensure referenced events are valid."""
657658 err_str = (
658659 "Window boundary reference must be either a valid alphanumeric/'_' string "
@@ -713,7 +714,7 @@ def _parse_boundary(cls, boundary: str) -> dict[str, str]:
713714 cls ._check_reference (ref )
714715 return {"referenced" : ref , "offset" : None , "event_bound" : None , "occurs_before" : None }
715716
716- def __post_init__ (self ):
717+ def __post_init__ (self ) -> None :
717718 # Parse the has constraints from the string representation to the tuple representation
718719 if self .has is not None :
719720 for each_constraint in self .has :
@@ -1132,7 +1133,11 @@ class TaskExtractorConfig:
11321133 index_timestamp_window : str | None = None
11331134
11341135 @classmethod
1135- def load (cls , config_path : str | Path , predicates_path : str | Path = None ) -> TaskExtractorConfig :
1136+ def load (
1137+ cls : TaskExtractorConfig ,
1138+ config_path : str | Path ,
1139+ predicates_path : str | Path = None ,
1140+ ) -> TaskExtractorConfig :
11361141 """Load a configuration file from the given path and return it as a dict.
11371142
11381143 Args:
@@ -1420,7 +1425,7 @@ def load(cls, config_path: str | Path, predicates_path: str | Path = None) -> Ta
14201425
14211426 return cls (predicates = predicate_objs , trigger = trigger , windows = windows )
14221427
1423- def _initialize_predicates (self ):
1428+ def _initialize_predicates (self ) -> None :
14241429 """Initialize the predicates tree from the configuration object and check validity.
14251430
14261431 Raises:
@@ -1467,7 +1472,7 @@ def _initialize_predicates(self):
14671472 f"Graph: { nx .write_network_text (self ._predicate_dag_graph )} "
14681473 )
14691474
1470- def _initialize_windows (self ):
1475+ def _initialize_windows (self ) -> None :
14711476 """Initialize the windows tree from the configuration object and check validity.
14721477
14731478 Raises:
@@ -1614,7 +1619,7 @@ def _initialize_windows(self):
16141619
16151620 self .window_nodes = window_nodes
16161621
1617- def __post_init__ (self ):
1622+ def __post_init__ (self ) -> None :
16181623 self ._initialize_predicates ()
16191624 self ._initialize_windows ()
16201625
@@ -1627,12 +1632,12 @@ def predicates_DAG(self) -> nx.DiGraph:
16271632 return self ._predicate_dag_graph
16281633
16291634 @property
1630- def plain_predicates (self ) -> dict [str : PlainPredicateConfig ]:
1635+ def plain_predicates (self ) -> dict [str , PlainPredicateConfig ]:
16311636 """Returns a dictionary of plain predicates in {name: code} format."""
16321637 return {p : cfg for p , cfg in self .predicates .items () if cfg .is_plain }
16331638
16341639 @property
1635- def derived_predicates (self ) -> OrderedDict [str : DerivedPredicateConfig ]:
1640+ def derived_predicates (self ) -> OrderedDict [str , DerivedPredicateConfig ]:
16361641 """Returns an ordered dictionary mapping derived predicates to their configs in a proper order."""
16371642 return {
16381643 p : self .predicates [p ]
0 commit comments