Matches only if the value is within the specified range.
| 287 | |
| 288 | |
| 289 | class InRange(Also): |
| 290 | """Matches only if the value is within the specified range.""" |
| 291 | |
| 292 | def __init__(self, pattern, start, stop): |
| 293 | super().__init__(pattern) |
| 294 | self.start = start |
| 295 | self.stop = stop |
| 296 | |
| 297 | def __repr__(self): |
| 298 | try: |
| 299 | return self.name |
| 300 | except AttributeError: |
| 301 | return f"({self.start!r} <= {self.pattern!r} < {self.stop!r})" |
| 302 | |
| 303 | def _also(self, value): |
| 304 | return self.start <= value < self.stop |
| 305 | |
| 306 | |
| 307 | class EqualTo(Also): |
no outgoing calls
no test coverage detected
searching dependent graphs…