Coverage for src/seqrule/generators/constraints.py: 89%

9 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-02-27 10:39 -0600

1""" 

2Constraints for sequence generation. 

3 

4This module provides constraint definitions for controlling 

5sequence generation. 

6""" 

7 

8from dataclasses import dataclass 

9from typing import Any, Callable 

10 

11 

12@dataclass 

13class Constraint: 

14 """Represents a constraint on sequence generation.""" 

15 

16 property_name: str 

17 condition: Callable[[Any], bool] 

18 description: str = "" 

19 

20 def __call__(self, value: Any) -> bool: 

21 """Apply the constraint to a value.""" 

22 return self.condition(value)