Skip to content

Commit 254c52c

Browse files
committed
use PEP 526-style annotations in os stubs
And fix some TODOs. This will help me check these stubs with my stubcheck tool, and is better for consistency anyway.
1 parent 0bda8c0 commit 254c52c

File tree

2 files changed

+206
-204
lines changed

2 files changed

+206
-204
lines changed

stdlib/2/os/__init__.pyi

Lines changed: 78 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -11,93 +11,94 @@ from mypy_extensions import NoReturn
1111

1212
_T = TypeVar('_T')
1313

14-
SEEK_SET = 0
15-
SEEK_CUR = 0
16-
SEEK_END = 0
14+
SEEK_SET: int
15+
SEEK_CUR: int
16+
SEEK_END: int
1717

1818
# More constants, copied from stdlib/3/os/__init__.pyi
19-
O_RDONLY = 0
20-
O_WRONLY = 0
21-
O_RDWR = 0
22-
O_APPEND = 0
23-
O_CREAT = 0
24-
O_EXCL = 0
25-
O_TRUNC = 0
26-
O_DSYNC = 0 # Unix only
27-
O_RSYNC = 0 # Unix only
28-
O_SYNC = 0 # Unix only
29-
O_NDELAY = 0 # Unix only
30-
O_NONBLOCK = 0 # Unix only
31-
O_NOCTTY = 0 # Unix only
32-
O_SHLOCK = 0 # Unix only
33-
O_EXLOCK = 0 # Unix only
34-
O_BINARY = 0 # Windows only
35-
O_NOINHERIT = 0 # Windows only
36-
O_SHORT_LIVED = 0 # Windows only
37-
O_TEMPORARY = 0 # Windows only
38-
O_RANDOM = 0 # Windows only
39-
O_SEQUENTIAL = 0 # Windows only
40-
O_TEXT = 0 # Windows only
41-
O_ASYNC = 0 # Gnu extension if in C library
42-
O_DIRECT = 0 # Gnu extension if in C library
43-
O_DIRECTORY = 0 # Gnu extension if in C library
44-
O_NOFOLLOW = 0 # Gnu extension if in C library
45-
O_NOATIME = 0 # Gnu extension if in C library
46-
O_LARGEFILE = 0 # Gnu extension if in C library
19+
O_RDONLY: int
20+
O_WRONLY: int
21+
O_RDWR: int
22+
O_APPEND: int
23+
O_CREAT: int
24+
O_EXCL: int
25+
O_TRUNC: int
26+
O_DSYNC: int # Unix only
27+
O_RSYNC: int # Unix only
28+
O_SYNC: int # Unix only
29+
O_NDELAY: int # Unix only
30+
O_NONBLOCK: int # Unix only
31+
O_NOCTTY: int # Unix only
32+
O_SHLOCK: int # Unix only
33+
O_EXLOCK: int # Unix only
34+
O_BINARY: int # Windows only
35+
O_NOINHERIT: int # Windows only
36+
O_SHORT_LIVED: int # Windows only
37+
O_TEMPORARY: int # Windows only
38+
O_RANDOM: int # Windows only
39+
O_SEQUENTIAL: int # Windows only
40+
O_TEXT: int # Windows only
41+
O_ASYNC: int # Gnu extension if in C library
42+
O_DIRECT: int # Gnu extension if in C library
43+
O_DIRECTORY: int # Gnu extension if in C library
44+
O_NOFOLLOW: int # Gnu extension if in C library
45+
O_NOATIME: int # Gnu extension if in C library
46+
O_LARGEFILE: int # Gnu extension if in C library
4747

48-
curdir = ... # type: str
49-
pardir = ... # type: str
50-
sep = ... # type: str
51-
altsep = ... # type: str
52-
extsep = ... # type: str
53-
pathsep = ... # type: str
54-
defpath = ... # type: str
55-
linesep = ... # type: str
56-
devnull = ... # type: str
57-
name = ... # type: str
48+
curdir: str
49+
pardir: str
50+
sep: str
51+
altsep: str
52+
extsep: str
53+
pathsep: str
54+
defpath: str
55+
linesep: str
56+
devnull: str
57+
name: str
5858

59-
F_OK = 0
60-
R_OK = 0
61-
W_OK = 0
62-
X_OK = 0
59+
F_OK: int
60+
R_OK: int
61+
W_OK: int
62+
X_OK: int
6363

6464
class _Environ(MutableMapping[AnyStr, AnyStr], Generic[AnyStr]):
6565
def copy(self) -> Dict[AnyStr, AnyStr]: ...
6666

67-
environ = ... # type: _Environ[str]
67+
environ: _Environ[str]
6868

69-
confstr_names = ... # type: Dict[str, int] # Unix only
70-
pathconf_names = ... # type: Dict[str, int] # Unix only
71-
sysconf_names = ... # type: Dict[str, int] # Unix only
69+
confstr_names: Dict[str, int] # Unix only
70+
pathconf_names: Dict[str, int] # Unix only
71+
sysconf_names: Dict[str, int] # Unix only
7272

73-
EX_OK = 0 # Unix only
74-
EX_USAGE = 0 # Unix only
75-
EX_DATAERR = 0 # Unix only
76-
EX_NOINPUT = 0 # Unix only
77-
EX_NOUSER = 0 # Unix only
78-
EX_NOHOST = 0 # Unix only
79-
EX_UNAVAILABLE = 0 # Unix only
80-
EX_SOFTWARE = 0 # Unix only
81-
EX_OSERR = 0 # Unix only
82-
EX_OSFILE = 0 # Unix only
83-
EX_CANTCREAT = 0 # Unix only
84-
EX_IOERR = 0 # Unix only
85-
EX_TEMPFAIL = 0 # Unix only
86-
EX_PROTOCOL = 0 # Unix only
87-
EX_NOPERM = 0 # Unix only
88-
EX_CONFIG = 0 # Unix only
89-
P_NOWAIT = 0
90-
P_NOWAITO = 0
91-
P_WAIT = 0
92-
# P_DETACH = 0 # Windows only
93-
# P_OVERLAY = 0 # Windows only
73+
EX_OK: int # Unix only
74+
EX_USAGE: int # Unix only
75+
EX_DATAERR: int # Unix only
76+
EX_NOINPUT: int # Unix only
77+
EX_NOUSER: int # Unix only
78+
EX_NOHOST: int # Unix only
79+
EX_UNAVAILABLE: int # Unix only
80+
EX_SOFTWARE: int # Unix only
81+
EX_OSERR: int # Unix only
82+
EX_OSFILE: int # Unix only
83+
EX_CANTCREAT: int # Unix only
84+
EX_IOERR: int # Unix only
85+
EX_TEMPFAIL: int # Unix only
86+
EX_PROTOCOL: int # Unix only
87+
EX_NOPERM: int # Unix only
88+
EX_CONFIG: int # Unix only
89+
P_NOWAIT: int
90+
P_NOWAITO: int
91+
P_WAIT: int
92+
if sys.platform == 'win32':
93+
P_DETACH: int # Windows only
94+
P_OVERLAY: int # Windows only
9495

9596
# wait()/waitpid() options
96-
WNOHANG = 0 # Unix only
97-
WCONTINUED = 0 # some Unix systems
98-
WUNTRACED = 0 # Unix only
97+
WNOHANG: int # Unix only
98+
WCONTINUED: int # some Unix systems
99+
WUNTRACED: int # Unix only
99100

100-
TMP_MAX = 0 # Undocumented, but used by tempfile
101+
TMP_MAX: int # Undocumented, but used by tempfile
101102
_PathType = Union[bytes, Text]
102103
_StatVFS = NamedTuple('_StatVFS', [('f_bsize', int), ('f_frsize', int), ('f_blocks', int),
103104
('f_bfree', int), ('f_bavail', int), ('f_files', int),
@@ -275,6 +276,6 @@ def tmpfile() -> IO[Any]: ...
275276
def tmpnam() -> str: ...
276277
def tempnam(dir: str = ..., prefix: str = ...) -> str: ...
277278

278-
P_ALL = 0
279-
WEXITED = 0
280-
WNOWAIT = 0
279+
P_ALL: int
280+
WEXITED: int
281+
WNOWAIT: int

0 commit comments

Comments
 (0)