Skip to content

Commit 57f7e83

Browse files
committed
borrow the updated re.pyi from typeshed
1 parent e554b2b commit 57f7e83

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

typeshed/2.7/re.pyi

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Stubs for re
2+
# Ron Murawski <[email protected]>
3+
# 'bytes' support added by Jukka Lehtosalo
4+
5+
# based on: http://docs.python.org/2.7/library/re.html
6+
7+
from typing import (
8+
List, Iterator, overload, Callable, Tuple, Sequence, Dict,
9+
Generic, AnyStr, Match, Pattern, Any
10+
)
11+
12+
# ----- re variables and constants -----
13+
DEBUG = 0
14+
I = 0
15+
IGNORECASE = 0
16+
L = 0
17+
LOCALE = 0
18+
M = 0
19+
MULTILINE = 0
20+
S = 0
21+
DOTALL = 0
22+
X = 0
23+
VERBOSE = 0
24+
U = 0
25+
UNICODE = 0
26+
T = 0
27+
TEMPLATE = 0
28+
29+
class error(Exception): ...
30+
31+
@overload
32+
def compile(pattern: AnyStr, flags: int = ...) -> Pattern[AnyStr]: ...
33+
@overload
34+
def compile(pattern: Pattern[AnyStr], flags: int = ...) -> Pattern[AnyStr]: ...
35+
36+
@overload
37+
def search(pattern: AnyStr, string: AnyStr, flags: int = ...) -> Match[AnyStr]: ...
38+
@overload
39+
def search(pattern: Pattern[AnyStr], string: AnyStr, flags: int = ...) -> Match[AnyStr]: ...
40+
41+
@overload
42+
def match(pattern: AnyStr, string: AnyStr, flags: int = ...) -> Match[AnyStr]: ...
43+
@overload
44+
def match(pattern: Pattern[AnyStr], string: AnyStr, flags: int = ...) -> Match[AnyStr]: ...
45+
46+
@overload
47+
def split(pattern: AnyStr, string: AnyStr,
48+
maxsplit: int = ..., flags: int = ...) -> List[AnyStr]: ...
49+
@overload
50+
def split(pattern: Pattern[AnyStr], string: AnyStr,
51+
maxsplit: int = ..., flags: int = ...) -> List[AnyStr]: ...
52+
53+
@overload
54+
def findall(pattern: AnyStr, string: AnyStr, flags: int = ...) -> List[Any]: ...
55+
@overload
56+
def findall(pattern: Pattern[AnyStr], string: AnyStr, flags: int = ...) -> List[Any]: ...
57+
58+
# Return an iterator yielding match objects over all non-overlapping matches
59+
# for the RE pattern in string. The string is scanned left-to-right, and
60+
# matches are returned in the order found. Empty matches are included in the
61+
# result unless they touch the beginning of another match.
62+
@overload
63+
def finditer(pattern: AnyStr, string: AnyStr,
64+
flags: int = ...) -> Iterator[Match[AnyStr]]: ...
65+
@overload
66+
def finditer(pattern: Pattern[AnyStr], string: AnyStr,
67+
flags: int = ...) -> Iterator[Match[AnyStr]]: ...
68+
69+
@overload
70+
def sub(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int = ...,
71+
flags: int = ...) -> AnyStr: ...
72+
@overload
73+
def sub(pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr],
74+
string: AnyStr, count: int = ..., flags: int = ...) -> AnyStr: ...
75+
@overload
76+
def sub(pattern: Pattern[AnyStr], repl: AnyStr, string: AnyStr, count: int = ...,
77+
flags: int = ...) -> AnyStr: ...
78+
@overload
79+
def sub(pattern: Pattern[AnyStr], repl: Callable[[Match[AnyStr]], AnyStr],
80+
string: AnyStr, count: int = ..., flags: int = ...) -> AnyStr: ...
81+
82+
@overload
83+
def subn(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int = ...,
84+
flags: int = ...) -> Tuple[AnyStr, int]: ...
85+
@overload
86+
def subn(pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr],
87+
string: AnyStr, count: int = ...,
88+
flags: int = ...) -> Tuple[AnyStr, int]: ...
89+
@overload
90+
def subn(pattern: Pattern[AnyStr], repl: AnyStr, string: AnyStr, count: int = ...,
91+
flags: int = ...) -> Tuple[AnyStr, int]: ...
92+
@overload
93+
def subn(pattern: Pattern[AnyStr], repl: Callable[[Match[AnyStr]], AnyStr],
94+
string: AnyStr, count: int = ...,
95+
flags: int = ...) -> Tuple[AnyStr, int]: ...
96+
97+
def escape(string: AnyStr) -> AnyStr: ...
98+
99+
def purge() -> None: ...

0 commit comments

Comments
 (0)