Big diff: Use new "|" union syntax (#5872)

This commit is contained in:
Akuli
2021-08-08 12:05:21 +03:00
committed by GitHub
parent b9adb7a874
commit ee487304d7
578 changed files with 8080 additions and 8966 deletions

View File

@@ -6,7 +6,7 @@ from _typeshed import StrPath
from collections.abc import Callable
from logging import FileHandler, Handler, LogRecord
from socket import SocketKind, socket
from typing import Any, ClassVar, Optional, Pattern, Union
from typing import Any, ClassVar, Pattern
if sys.version_info >= (3, 7):
from queue import Queue, SimpleQueue
@@ -25,27 +25,22 @@ class WatchedFileHandler(FileHandler):
ino: int # undocumented
if sys.version_info >= (3, 9):
def __init__(
self,
filename: StrPath,
mode: str = ...,
encoding: Optional[str] = ...,
delay: bool = ...,
errors: Optional[str] = ...,
self, filename: StrPath, mode: str = ..., encoding: str | None = ..., delay: bool = ..., errors: str | None = ...
) -> None: ...
else:
def __init__(self, filename: StrPath, mode: str = ..., encoding: Optional[str] = ..., delay: bool = ...) -> None: ...
def __init__(self, filename: StrPath, mode: str = ..., encoding: str | None = ..., delay: bool = ...) -> None: ...
def _statstream(self) -> None: ... # undocumented
def reopenIfNeeded(self) -> None: ...
class BaseRotatingHandler(FileHandler):
namer: Optional[Callable[[str], str]]
rotator: Optional[Callable[[str, str], None]]
namer: Callable[[str], str] | None
rotator: Callable[[str, str], None] | None
if sys.version_info >= (3, 9):
def __init__(
self, filename: StrPath, mode: str, encoding: Optional[str] = ..., delay: bool = ..., errors: Optional[str] = ...
self, filename: StrPath, mode: str, encoding: str | None = ..., delay: bool = ..., errors: str | None = ...
) -> None: ...
else:
def __init__(self, filename: StrPath, mode: str, encoding: Optional[str] = ..., delay: bool = ...) -> None: ...
def __init__(self, filename: StrPath, mode: str, encoding: str | None = ..., delay: bool = ...) -> None: ...
def rotation_filename(self, default_name: str) -> str: ...
def rotate(self, source: str, dest: str) -> None: ...
@@ -59,9 +54,9 @@ class RotatingFileHandler(BaseRotatingHandler):
mode: str = ...,
maxBytes: int = ...,
backupCount: int = ...,
encoding: Optional[str] = ...,
encoding: str | None = ...,
delay: bool = ...,
errors: Optional[str] = ...,
errors: str | None = ...,
) -> None: ...
else:
def __init__(
@@ -70,7 +65,7 @@ class RotatingFileHandler(BaseRotatingHandler):
mode: str = ...,
maxBytes: int = ...,
backupCount: int = ...,
encoding: Optional[str] = ...,
encoding: str | None = ...,
delay: bool = ...,
) -> None: ...
def doRollover(self) -> None: ...
@@ -80,7 +75,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
when: str # undocumented
backupCount: str # undocumented
utc: bool # undocumented
atTime: Optional[datetime.datetime] # undocumented
atTime: datetime.datetime | None # undocumented
interval: int # undocumented
suffix: str # undocumented
dayOfWeek: int # undocumented
@@ -93,11 +88,11 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
when: str = ...,
interval: int = ...,
backupCount: int = ...,
encoding: Optional[str] = ...,
encoding: str | None = ...,
delay: bool = ...,
utc: bool = ...,
atTime: Optional[datetime.datetime] = ...,
errors: Optional[str] = ...,
atTime: datetime.datetime | None = ...,
errors: str | None = ...,
) -> None: ...
else:
def __init__(
@@ -106,10 +101,10 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
when: str = ...,
interval: int = ...,
backupCount: int = ...,
encoding: Optional[str] = ...,
encoding: str | None = ...,
delay: bool = ...,
utc: bool = ...,
atTime: Optional[datetime.datetime] = ...,
atTime: datetime.datetime | None = ...,
) -> None: ...
def doRollover(self) -> None: ...
def shouldRollover(self, record: LogRecord) -> int: ... # undocumented
@@ -118,15 +113,15 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
class SocketHandler(Handler):
host: str # undocumented
port: Optional[int] # undocumented
address: Union[tuple[str, int], str] # undocumented
sock: Optional[socket] # undocumented
port: int | None # undocumented
address: tuple[str, int] | str # undocumented
sock: socket | None # undocumented
closeOnError: bool # undocumented
retryTime: Optional[float] # undocumented
retryTime: float | None # undocumented
retryStart: float # undocumented
retryFactor: float # undocumented
retryMax: float # undocumented
def __init__(self, host: str, port: Optional[int]) -> None: ...
def __init__(self, host: str, port: int | None) -> None: ...
def makeSocket(self, timeout: float = ...) -> socket: ... # timeout is undocumented
def makePickle(self, record: LogRecord) -> bytes: ...
def send(self, s: bytes) -> None: ...
@@ -180,14 +175,12 @@ class SysLogHandler(Handler):
priority_names: ClassVar[dict[str, int]] # undocumented
facility_names: ClassVar[dict[str, int]] # undocumented
priority_map: ClassVar[dict[str, str]] # undocumented
def __init__(
self, address: Union[tuple[str, int], str] = ..., facility: int = ..., socktype: Optional[SocketKind] = ...
) -> None: ...
def encodePriority(self, facility: Union[int, str], priority: Union[int, str]) -> int: ...
def __init__(self, address: tuple[str, int] | str = ..., facility: int = ..., socktype: SocketKind | None = ...) -> None: ...
def encodePriority(self, facility: int | str, priority: int | str) -> int: ...
def mapPriority(self, levelName: str) -> str: ...
class NTEventLogHandler(Handler):
def __init__(self, appname: str, dllname: Optional[str] = ..., logtype: str = ...) -> None: ...
def __init__(self, appname: str, dllname: str | None = ..., logtype: str = ...) -> None: ...
def getEventCategory(self, record: LogRecord) -> int: ...
# TODO correct return value?
def getEventType(self, record: LogRecord) -> int: ...
@@ -195,23 +188,23 @@ class NTEventLogHandler(Handler):
class SMTPHandler(Handler):
mailhost: str # undocumented
mailport: Optional[int] # undocumented
username: Optional[str] # undocumented
mailport: int | None # undocumented
username: str | None # undocumented
# password only exists as an attribute if passed credentials is a tuple or list
password: str # undocumented
fromaddr: str # undocumented
toaddrs: list[str] # undocumented
subject: str # undocumented
secure: Union[tuple[()], tuple[str], tuple[str, str], None] # undocumented
secure: tuple[()] | tuple[str] | tuple[str, str] | None # undocumented
timeout: float # undocumented
def __init__(
self,
mailhost: Union[str, tuple[str, int]],
mailhost: str | tuple[str, int],
fromaddr: str,
toaddrs: Union[str, list[str]],
toaddrs: str | list[str],
subject: str,
credentials: Optional[tuple[str, str]] = ...,
secure: Union[tuple[()], tuple[str], tuple[str, str], None] = ...,
credentials: tuple[str, str] | None = ...,
secure: tuple[()] | tuple[str] | tuple[str, str] | None = ...,
timeout: float = ...,
) -> None: ...
def getSubject(self, record: LogRecord) -> str: ...
@@ -224,28 +217,26 @@ class BufferingHandler(Handler):
class MemoryHandler(BufferingHandler):
flushLevel: int # undocumented
target: Optional[Handler] # undocumented
target: Handler | None # undocumented
flushOnClose: bool # undocumented
def __init__(
self, capacity: int, flushLevel: int = ..., target: Optional[Handler] = ..., flushOnClose: bool = ...
) -> None: ...
def setTarget(self, target: Optional[Handler]) -> None: ...
def __init__(self, capacity: int, flushLevel: int = ..., target: Handler | None = ..., flushOnClose: bool = ...) -> None: ...
def setTarget(self, target: Handler | None) -> None: ...
class HTTPHandler(Handler):
host: str # undocumented
url: str # undocumented
method: str # undocumented
secure: bool # undocumented
credentials: Optional[tuple[str, str]] # undocumented
context: Optional[ssl.SSLContext] # undocumented
credentials: tuple[str, str] | None # undocumented
context: ssl.SSLContext | None # undocumented
def __init__(
self,
host: str,
url: str,
method: str = ...,
secure: bool = ...,
credentials: Optional[tuple[str, str]] = ...,
context: Optional[ssl.SSLContext] = ...,
credentials: tuple[str, str] | None = ...,
context: ssl.SSLContext | None = ...,
) -> None: ...
def mapLogRecord(self, record: LogRecord) -> dict[str, Any]: ...
if sys.version_info >= (3, 9):
@@ -253,8 +244,8 @@ class HTTPHandler(Handler):
class QueueHandler(Handler):
if sys.version_info >= (3, 7):
queue: Union[SimpleQueue[Any], Queue[Any]] # undocumented
def __init__(self, queue: Union[SimpleQueue[Any], Queue[Any]]) -> None: ...
queue: SimpleQueue[Any] | Queue[Any] # undocumented
def __init__(self, queue: SimpleQueue[Any] | Queue[Any]) -> None: ...
else:
queue: Queue[Any] # undocumented
def __init__(self, queue: Queue[Any]) -> None: ...
@@ -265,9 +256,9 @@ class QueueListener:
handlers: tuple[Handler] # undocumented
respect_handler_level: bool # undocumented
if sys.version_info >= (3, 7):
queue: Union[SimpleQueue[Any], Queue[Any]] # undocumented
queue: SimpleQueue[Any] | Queue[Any] # undocumented
def __init__(
self, queue: Union[SimpleQueue[Any], Queue[Any]], *handlers: Handler, respect_handler_level: bool = ...
self, queue: SimpleQueue[Any] | Queue[Any], *handlers: Handler, respect_handler_level: bool = ...
) -> None: ...
else:
queue: Queue[Any] # undocumented