Skip to content

Commit efdf2f1

Browse files
JelleZijlstraambv
authored andcommitted
add compileall stubs to 3 and add types to the ones in 2 (#1023)
* add compileall stubs to 3 and add types to the ones in 2 Didn't merge the stubs because all functions have additional parameters since 3.2, so there would be no shared code between 2 and 3. * add comment
1 parent 50327f0 commit efdf2f1

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

stdlib/2/compileall.pyi

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Stubs for compileall (Python 2)
2-
#
3-
# NOTE: This dynamically typed stub was automatically generated by stubgen.
42

5-
def compile_dir(dir, maxlevels=..., ddir=..., force=..., rx=..., quiet=...): ...
6-
def compile_file(fullname, ddir=..., force=..., rx=..., quiet=...): ...
7-
def compile_path(skip_curdir=..., maxlevels=..., force=..., quiet=...): ...
3+
from typing import Optional, Pattern, Union
4+
5+
_Path = Union[str, bytes]
6+
7+
# fx can be any object with a 'search' method; once we have Protocols we can change the type
8+
def compile_dir(dir: _Path, maxlevels: int = ..., ddir: _Path = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ...) -> None: ...
9+
def compile_file(fullname: _Path, ddir: _Path = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ...) -> None: ...
10+
def compile_path(skip_curdir: bool = ..., maxlevels: int = ..., force: bool = ..., quiet: int = ...) -> None: ...

stdlib/3/compileall.pyi

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Stubs for compileall (Python 3)
2+
3+
import os
4+
import sys
5+
from typing import Optional, Union, Pattern
6+
7+
if sys.version_info < (3, 6):
8+
_Path = Union[str, bytes]
9+
else:
10+
_Path = Union[str, bytes, os.PathLike]
11+
12+
# fx can be any object with a 'search' method; once we have Protocols we can change the type
13+
if sys.version_info < (3, 5):
14+
def compile_dir(dir: _Path, maxlevels: int = ..., ddir: _Path = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ...) -> None: ...
15+
else:
16+
def compile_dir(dir: _Path, maxlevels: int = ..., ddir: _Path = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ..., workers: int = ...) -> None: ...
17+
def compile_file(fullname: _Path, ddir: _Path = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ...) -> None: ...
18+
def compile_path(skip_curdir: bool = ..., maxlevels: int = ..., force: bool = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ...) -> None: ...

0 commit comments

Comments
 (0)