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
@@ -289,7 +290,7 @@ class DerivedPredicateConfig:
289290 expr : str
290291 static : bool = False
291292
292- def __post_init__ (self ):
293+ def __post_init__ (self ) -> None :
293294 if not self .expr :
294295 raise ValueError ("Derived predicates must have a non-empty expression field." )
295296
@@ -647,7 +648,7 @@ class WindowConfig:
647648 index_timestamp : str | None = None
648649
649650 @classmethod
650- def _check_reference (cls , reference : str ):
651+ def _check_reference (cls , reference : str ) -> None :
651652 """Checks to ensure referenced events are valid."""
652653 err_str = (
653654 "Window boundary reference must be either a valid alphanumeric/'_' string "
@@ -708,7 +709,7 @@ def _parse_boundary(cls, boundary: str) -> dict[str, str]:
708709 cls ._check_reference (ref )
709710 return {"referenced" : ref , "offset" : None , "event_bound" : None , "occurs_before" : None }
710711
711- def __post_init__ (self ):
712+ def __post_init__ (self ) -> None :
712713 # Parse the has constraints from the string representation to the tuple representation
713714 if self .has is not None :
714715 for each_constraint in self .has :
@@ -1127,7 +1128,11 @@ class TaskExtractorConfig:
11271128 index_timestamp_window : str | None = None
11281129
11291130 @classmethod
1130- def load (cls , config_path : str | Path , predicates_path : str | Path = None ) -> TaskExtractorConfig :
1131+ def load (
1132+ cls : TaskExtractorConfig ,
1133+ config_path : str | Path ,
1134+ predicates_path : str | Path = None ,
1135+ ) -> TaskExtractorConfig :
11311136 """Load a configuration file from the given path and return it as a dict.
11321137
11331138 Args:
@@ -1308,7 +1313,7 @@ def load(cls, config_path: str | Path, predicates_path: str | Path = None) -> Ta
13081313
13091314 return cls (predicates = predicate_objs , trigger = trigger , windows = windows )
13101315
1311- def _initialize_predicates (self ):
1316+ def _initialize_predicates (self ) -> None :
13121317 """Initialize the predicates tree from the configuration object and check validity.
13131318
13141319 Raises:
@@ -1355,7 +1360,7 @@ def _initialize_predicates(self):
13551360 f"Graph: { nx .write_network_text (self ._predicate_dag_graph )} "
13561361 )
13571362
1358- def _initialize_windows (self ):
1363+ def _initialize_windows (self ) -> None :
13591364 """Initialize the windows tree from the configuration object and check validity.
13601365
13611366 Raises:
@@ -1502,7 +1507,7 @@ def _initialize_windows(self):
15021507
15031508 self .window_nodes = window_nodes
15041509
1505- def __post_init__ (self ):
1510+ def __post_init__ (self ) -> None :
15061511 self ._initialize_predicates ()
15071512 self ._initialize_windows ()
15081513
@@ -1515,12 +1520,12 @@ def predicates_DAG(self) -> nx.DiGraph:
15151520 return self ._predicate_dag_graph
15161521
15171522 @property
1518- def plain_predicates (self ) -> dict [str : PlainPredicateConfig ]:
1523+ def plain_predicates (self ) -> dict [str , PlainPredicateConfig ]:
15191524 """Returns a dictionary of plain predicates in {name: code} format."""
15201525 return {p : cfg for p , cfg in self .predicates .items () if cfg .is_plain }
15211526
15221527 @property
1523- def derived_predicates (self ) -> OrderedDict [str : DerivedPredicateConfig ]:
1528+ def derived_predicates (self ) -> OrderedDict [str , DerivedPredicateConfig ]:
15241529 """Returns an ordered dictionary mapping derived predicates to their configs in a proper order."""
15251530 return {
15261531 p : self .predicates [p ]
0 commit comments