Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pathspec/backend.py: 86%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2This module defines the necessary classes and type hints for exposing the bare
3minimum of the internal implementations for the pattern (regular expression)
4matching backends. The exact structure of the backends is not solidified and is
5subject to change.
6"""
8from typing import (
9 Literal,
10 Optional)
12BackendNamesHint = Literal['best', 'hyperscan', 're2', 'simple']
13"""
14The supported backend values.
15"""
18class _Backend(object):
19 """
20 .. warning:: This class is not part of the public API. It is subject to
21 change.
23 The :class:`_Backend` class is the abstract base class defining how to match
24 files against patterns.
25 """
27 def match_file(self, file: str) -> tuple[Optional[bool], Optional[int]]:
28 """
29 Check the file against the patterns.
31 *file* (:class:`str`) is the normalized file path to check.
33 Returns a :class:`tuple` containing whether to include *file* (:class:`bool`
34 or :data:`None`), and the index of the last matched pattern (:class:`int` or
35 :data:`None`).
36 """
37 raise NotImplementedError((
38 f"{self.__class__.__module__}.{self.__class__.__qualname__}.match_file() "
39 f"must be implemented."
40 )) # NotImplementedError