use _typeshed's Path aliases (#4214)

This commit is contained in:
Jelle Zijlstra
2020-06-10 20:57:09 -07:00
committed by GitHub
parent 86f03f2d7b
commit 43e93f803f
42 changed files with 483 additions and 757 deletions

View File

@@ -1,14 +1,10 @@
# Stubs for compileall (Python 3)
import os
import sys
from typing import Any, Optional, Union, Pattern
from _typeshed import AnyPath
from typing import Any, Optional, Pattern
if sys.version_info < (3, 6):
_Path = Union[str, bytes]
_SuccessType = bool
else:
_Path = Union[str, bytes, os.PathLike]
_SuccessType = int
if sys.version_info >= (3, 7):
@@ -16,9 +12,9 @@ if sys.version_info >= (3, 7):
if sys.version_info >= (3, 9):
def compile_dir(
dir: _Path,
dir: AnyPath,
maxlevels: Optional[int] = ...,
ddir: Optional[_Path] = ...,
ddir: Optional[AnyPath] = ...,
force: bool = ...,
rx: Optional[Pattern[Any]] = ...,
quiet: int = ...,
@@ -27,13 +23,13 @@ if sys.version_info >= (3, 9):
workers: int = ...,
invalidation_mode: Optional[PycInvalidationMode] = ...,
*,
stripdir: Optional[str] = ..., # TODO: change to Optional[_Path] once https://bugs.python.org/issue40447 is resolved
prependdir: Optional[_Path] = ...,
limit_sl_dest: Optional[_Path] = ...,
stripdir: Optional[str] = ..., # TODO: change to Optional[AnyPath] once https://bugs.python.org/issue40447 is resolved
prependdir: Optional[AnyPath] = ...,
limit_sl_dest: Optional[AnyPath] = ...,
) -> _SuccessType: ...
def compile_file(
fullname: _Path,
ddir: Optional[_Path] = ...,
fullname: AnyPath,
ddir: Optional[AnyPath] = ...,
force: bool = ...,
rx: Optional[Pattern[Any]] = ...,
quiet: int = ...,
@@ -41,15 +37,15 @@ if sys.version_info >= (3, 9):
optimize: int = ...,
invalidation_mode: Optional[PycInvalidationMode] = ...,
*,
stripdir: Optional[str] = ..., # TODO: change to Optional[_Path] once https://bugs.python.org/issue40447 is resolved
prependdir: Optional[_Path] = ...,
limit_sl_dest: Optional[_Path] = ...,
stripdir: Optional[str] = ..., # TODO: change to Optional[AnyPath] once https://bugs.python.org/issue40447 is resolved
prependdir: Optional[AnyPath] = ...,
limit_sl_dest: Optional[AnyPath] = ...,
) -> _SuccessType: ...
elif sys.version_info >= (3, 7):
def compile_dir(
dir: _Path,
dir: AnyPath,
maxlevels: int = ...,
ddir: Optional[_Path] = ...,
ddir: Optional[AnyPath] = ...,
force: bool = ...,
rx: Optional[Pattern[Any]] = ...,
quiet: int = ...,
@@ -59,8 +55,8 @@ elif sys.version_info >= (3, 7):
invalidation_mode: Optional[PycInvalidationMode] = ...,
) -> _SuccessType: ...
def compile_file(
fullname: _Path,
ddir: Optional[_Path] = ...,
fullname: AnyPath,
ddir: Optional[AnyPath] = ...,
force: bool = ...,
rx: Optional[Pattern[Any]] = ...,
quiet: int = ...,
@@ -72,9 +68,9 @@ elif sys.version_info >= (3, 7):
else:
# rx can be any object with a 'search' method; once we have Protocols we can change the type
def compile_dir(
dir: _Path,
dir: AnyPath,
maxlevels: int = ...,
ddir: Optional[_Path] = ...,
ddir: Optional[AnyPath] = ...,
force: bool = ...,
rx: Optional[Pattern[Any]] = ...,
quiet: int = ...,
@@ -83,8 +79,8 @@ else:
workers: int = ...,
) -> _SuccessType: ...
def compile_file(
fullname: _Path,
ddir: Optional[_Path] = ...,
fullname: AnyPath,
ddir: Optional[AnyPath] = ...,
force: bool = ...,
rx: Optional[Pattern[Any]] = ...,
quiet: int = ...,