##// END OF EJS Templates
typing: add type hints for the overloads of `matchmod.readpatternfile()`...
Matt Harbison -
r52819:70fe33bd default
parent child Browse files
Show More
@@ -12,6 +12,16 b' import copy'
12 import itertools
12 import itertools
13 import os
13 import os
14 import re
14 import re
15 import typing
16
17 from typing import (
18 Any,
19 Callable,
20 List,
21 Tuple,
22 Union,
23 overload,
24 )
15
25
16 from .i18n import _
26 from .i18n import _
17 from .pycompat import open
27 from .pycompat import open
@@ -1664,6 +1674,33 b' def _prefix(kindpats):'
1664
1674
1665 _commentre = None
1675 _commentre = None
1666
1676
1677 if typing.TYPE_CHECKING:
1678 from typing_extensions import (
1679 Literal,
1680 )
1681
1682 @overload
1683 def readpatternfile(
1684 filepath: bytes, warn: Callable[[bytes], Any], sourceinfo: Literal[True]
1685 ) -> List[Tuple[bytes, int, bytes]]:
1686 ...
1687
1688 @overload
1689 def readpatternfile(
1690 filepath: bytes,
1691 warn: Callable[[bytes], Any],
1692 sourceinfo: Literal[False],
1693 ) -> List[bytes]:
1694 ...
1695
1696 @overload
1697 def readpatternfile(
1698 filepath: bytes,
1699 warn: Callable[[bytes], Any],
1700 sourceinfo: bool = False,
1701 ) -> List[Union[Tuple[bytes, int, bytes], bytes]]:
1702 ...
1703
1667
1704
1668 def readpatternfile(filepath, warn, sourceinfo=False):
1705 def readpatternfile(filepath, warn, sourceinfo=False):
1669 """parse a pattern file, returning a list of
1706 """parse a pattern file, returning a list of
General Comments 0
You need to be logged in to leave comments. Login now