1"""
2This module defines base classes for implementing pattern (or regex) matching
3backends.
4
5WARNING: The *pathspec._backends* package is not part of the public API. Its
6contents and structure are likely to change.
7"""
8
9from typing import (
10 Literal,
11 Optional)
12
13BackendNamesHint = Literal['best', 'hyperscan', 'simple']
14
15
16class Backend(object):
17 """
18 The :class:`Backend` class is the abstract base class defining how to match
19 files against patterns.
20 """
21
22 def match_file(self, file: str) -> tuple[Optional[bool], Optional[int]]:
23 """
24 Check the file against the patterns.
25
26 *file* (:class:`str`) is the normalized file path to check.
27
28 Returns a :class:`tuple` containing whether to include *file* (:class:`bool`
29 or :data:`None`), and the index of the last matched pattern (:class:`int` or
30 :data:`None`).
31 """
32 raise NotImplementedError((
33 f"{self.__class__.__module__}.{self.__class__.__qualname__}.match_file() "
34 f"must be implemented."
35 )) # NotImplementedError