massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / re.pyi
1 import enum
2 import sys
3 from sre_constants import error as error
4 from typing import Any, AnyStr, Callable, Iterator, Union, overload
5
6 # ----- re variables and constants -----
7 if sys.version_info >= (3, 7):
8     from typing import Match as Match, Pattern as Pattern
9 else:
10     from typing import Match, Pattern
11
12 class RegexFlag(enum.IntFlag):
13     A: int
14     ASCII: int
15     DEBUG: int
16     I: int
17     IGNORECASE: int
18     L: int
19     LOCALE: int
20     M: int
21     MULTILINE: int
22     S: int
23     DOTALL: int
24     X: int
25     VERBOSE: int
26     U: int
27     UNICODE: int
28     T: int
29     TEMPLATE: int
30
31 A = RegexFlag.A
32 ASCII = RegexFlag.ASCII
33 DEBUG = RegexFlag.DEBUG
34 I = RegexFlag.I
35 IGNORECASE = RegexFlag.IGNORECASE
36 L = RegexFlag.L
37 LOCALE = RegexFlag.LOCALE
38 M = RegexFlag.M
39 MULTILINE = RegexFlag.MULTILINE
40 S = RegexFlag.S
41 DOTALL = RegexFlag.DOTALL
42 X = RegexFlag.X
43 VERBOSE = RegexFlag.VERBOSE
44 U = RegexFlag.U
45 UNICODE = RegexFlag.UNICODE
46 T = RegexFlag.T
47 TEMPLATE = RegexFlag.TEMPLATE
48 _FlagsType = Union[int, RegexFlag]
49
50 if sys.version_info < (3, 7):
51     # undocumented
52     _pattern_type: type
53
54 @overload
55 def compile(pattern: AnyStr, flags: _FlagsType = ...) -> Pattern[AnyStr]: ...
56 @overload
57 def compile(pattern: Pattern[AnyStr], flags: _FlagsType = ...) -> Pattern[AnyStr]: ...
58 @overload
59 def search(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr] | None: ...
60 @overload
61 def search(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr] | None: ...
62 @overload
63 def match(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr] | None: ...
64 @overload
65 def match(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr] | None: ...
66
67 # New in Python 3.4
68 @overload
69 def fullmatch(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr] | None: ...
70 @overload
71 def fullmatch(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr] | None: ...
72 @overload
73 def split(pattern: AnyStr, string: AnyStr, maxsplit: int = ..., flags: _FlagsType = ...) -> list[AnyStr | Any]: ...
74 @overload
75 def split(pattern: Pattern[AnyStr], string: AnyStr, maxsplit: int = ..., flags: _FlagsType = ...) -> list[AnyStr | Any]: ...
76 @overload
77 def findall(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> list[Any]: ...
78 @overload
79 def findall(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> list[Any]: ...
80
81 # Return an iterator yielding match objects over all non-overlapping matches
82 # for the RE pattern in string. The string is scanned left-to-right, and
83 # matches are returned in the order found. Empty matches are included in the
84 # result unless they touch the beginning of another match.
85 @overload
86 def finditer(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> Iterator[Match[AnyStr]]: ...
87 @overload
88 def finditer(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> Iterator[Match[AnyStr]]: ...
89 @overload
90 def sub(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int = ..., flags: _FlagsType = ...) -> AnyStr: ...
91 @overload
92 def sub(
93     pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: _FlagsType = ...
94 ) -> AnyStr: ...
95 @overload
96 def sub(pattern: Pattern[AnyStr], repl: AnyStr, string: AnyStr, count: int = ..., flags: _FlagsType = ...) -> AnyStr: ...
97 @overload
98 def sub(
99     pattern: Pattern[AnyStr], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: _FlagsType = ...
100 ) -> AnyStr: ...
101 @overload
102 def subn(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int = ..., flags: _FlagsType = ...) -> tuple[AnyStr, int]: ...
103 @overload
104 def subn(
105     pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: _FlagsType = ...
106 ) -> tuple[AnyStr, int]: ...
107 @overload
108 def subn(
109     pattern: Pattern[AnyStr], repl: AnyStr, string: AnyStr, count: int = ..., flags: _FlagsType = ...
110 ) -> tuple[AnyStr, int]: ...
111 @overload
112 def subn(
113     pattern: Pattern[AnyStr], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: _FlagsType = ...
114 ) -> tuple[AnyStr, int]: ...
115 def escape(pattern: AnyStr) -> AnyStr: ...
116 def purge() -> None: ...
117 def template(pattern: AnyStr | Pattern[AnyStr], flags: _FlagsType = ...) -> Pattern[AnyStr]: ...