Specification pattern: Difference between revisions

Content deleted Content added
Python: bugfixes
Line 233:
=== [[Python (programming language)|Python]] ===
<syntaxhighlight lang="python">
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Any
 
class BaseSpecification(ABC):
@abstractmethod
def is_satisfied_by(self, candidate: Any) -> bool:
Line 243:
 
def __call__(self, candidate: Any) -> bool:
return self.is_satisfied_by(candidate)
 
def __and__(self, other: "BaseSpecification") -> "AndSpecification":