[docs]classPointlessCompound(UserWarning):"""Emitted if you create a compound matcher with a single child matcher."""MESSAGE:tp.ClassVar[str]=("a compound matcher with a single child matcher can be trivially replaced by that child")
[docs]classZeroMatchers(TypeError):"""Thrown if you try to create a compound matcher with no child matchers."""MESSAGE:tp.ClassVar[str]="compound matchers require at least one child matcher"def__init__(self)->None:super().__init__(self.MESSAGE)
[docs]classAllOf(_Compound[T]):"""Matches values which match all of the child matchers. .. note:: Unlike :py:func:`all` this comparison is not lazy; all matchers are compared, whether or not any are unequal. """defcompare(self,other:tp.Any)->bool:equal:bool=Trueformatcherinself._matchers:ifmatcher!=other:equal=Falsereturnequal
[docs]classAnyOf(_Compound[T]):"""Matches values which match any of the child matchers. .. note:: Unlike :py:func:`any` this comparison is not lazy; all matchers are compared, whether or not any are equal. """defcompare(self,other:tp.Any)->bool:equal:bool=Falseformatcherinself._matchers:ifmatcher==other:equal=Truereturnequal