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,5 +1,4 @@
# Stubs for logging (Python 3.7)
from _typeshed import StrPath
from typing import (
Any, Callable, Dict, Iterable, List, Mapping, MutableMapping, Optional, IO,
Sequence, Tuple, Text, Union, overload,
@@ -19,11 +18,6 @@ else:
_ArgsType = Union[Tuple[Any, ...], Mapping[str, Any]]
_FilterType = Union[Filter, Callable[[LogRecord], int]]
_Level = Union[int, Text]
if sys.version_info >= (3, 6):
from os import PathLike
_Path = Union[str, PathLike[str]]
else:
_Path = str
raiseExceptions: bool
logThreads: bool
@@ -474,12 +468,12 @@ def getLevelName(level: Union[int, str]) -> Any: ...
def makeLogRecord(dict: Mapping[str, Any]) -> LogRecord: ...
if sys.version_info >= (3, 8):
def basicConfig(*, filename: Optional[_Path] = ..., filemode: str = ...,
def basicConfig(*, filename: Optional[StrPath] = ..., filemode: str = ...,
format: str = ..., datefmt: Optional[str] = ..., style: str = ...,
level: Optional[_Level] = ..., stream: Optional[IO[str]] = ...,
handlers: Optional[Iterable[Handler]] = ..., force: bool = ...) -> None: ...
elif sys.version_info >= (3,):
def basicConfig(*, filename: Optional[_Path] = ..., filemode: str = ...,
def basicConfig(*, filename: Optional[StrPath] = ..., filemode: str = ...,
format: str = ..., datefmt: Optional[str] = ..., style: str = ...,
level: Optional[_Level] = ..., stream: Optional[IO[str]] = ...,
handlers: Optional[Iterable[Handler]] = ...) -> None: ...
@@ -518,7 +512,7 @@ class FileHandler(StreamHandler):
mode: str # undocumented
encoding: Optional[str] # undocumented
delay: bool # undocumented
def __init__(self, filename: _Path, mode: str = ...,
def __init__(self, filename: StrPath, mode: str = ...,
encoding: Optional[str] = ..., delay: bool = ...) -> None: ...
def _open(self) -> IO[Any]: ...

View File

@@ -1,5 +1,4 @@
# Stubs for logging.config (Python 3.4)
from _typeshed import AnyPath, StrPath
from typing import Any, Callable, Dict, Optional, IO, Union
from threading import Thread
import sys
@@ -7,15 +6,11 @@ if sys.version_info >= (3,):
from configparser import RawConfigParser
else:
from ConfigParser import RawConfigParser
if sys.version_info >= (3, 6):
from os import PathLike
if sys.version_info >= (3, 7):
_Path = Union[str, bytes, PathLike[str]]
elif sys.version_info >= (3, 6):
_Path = Union[str, PathLike[str]]
_Path = AnyPath
else:
_Path = str
_Path = StrPath
def dictConfig(config: Dict[str, Any]) -> None: ...

View File

@@ -1,5 +1,4 @@
# Stubs for logging.handlers (Python 2.4)
from _typeshed import StrPath
import datetime
from logging import Handler, FileHandler, LogRecord
from socket import SocketType
@@ -15,11 +14,6 @@ else:
# TODO update socket stubs to add SocketKind
_SocketKind = int
if sys.version_info >= (3, 6):
from os import PathLike
_Path = Union[str, PathLike[str]]
else:
_Path = str
DEFAULT_TCP_LOGGING_PORT: int
DEFAULT_UDP_LOGGING_PORT: int
@@ -31,7 +25,7 @@ SYSLOG_TCP_PORT: int
class WatchedFileHandler(FileHandler):
dev: int
ino: int
def __init__(self, filename: _Path, mode: str = ..., encoding: Optional[str] = ...,
def __init__(self, filename: StrPath, mode: str = ..., encoding: Optional[str] = ...,
delay: bool = ...) -> None: ...
def _statstream(self) -> None: ...
@@ -41,7 +35,7 @@ if sys.version_info >= (3,):
terminator: str
namer: Optional[Callable[[str], str]]
rotator: Optional[Callable[[str, str], None]]
def __init__(self, filename: _Path, mode: str,
def __init__(self, filename: StrPath, mode: str,
encoding: Optional[str] = ...,
delay: bool = ...) -> None: ...
def rotation_filename(self, default_name: str) -> None: ...
@@ -50,7 +44,7 @@ if sys.version_info >= (3,):
if sys.version_info >= (3,):
class RotatingFileHandler(BaseRotatingHandler):
def __init__(self, filename: _Path, mode: str = ..., maxBytes: int = ...,
def __init__(self, filename: StrPath, mode: str = ..., maxBytes: int = ...,
backupCount: int = ..., encoding: Optional[str] = ...,
delay: bool = ...) -> None: ...
def doRollover(self) -> None: ...
@@ -65,7 +59,7 @@ else:
if sys.version_info >= (3,):
class TimedRotatingFileHandler(BaseRotatingHandler):
if sys.version_info >= (3, 4):
def __init__(self, filename: _Path, when: str = ...,
def __init__(self, filename: StrPath, when: str = ...,
interval: int = ...,
backupCount: int = ..., encoding: Optional[str] = ...,
delay: bool = ..., utc: bool = ...,