Use PEP 570 syntax in stdlib (#11250)

This commit is contained in:
Shantanu
2024-03-09 14:50:16 -08:00
committed by GitHub
parent 63737acac6
commit 470a13ab09
139 changed files with 2412 additions and 2371 deletions

View File

@@ -217,9 +217,9 @@ if sys.version_info >= (3, 12):
# Can take or return anything depending on what's in the registry.
@overload
def adapt(__obj: Any, __proto: Any) -> Any: ...
def adapt(obj: Any, proto: Any, /) -> Any: ...
@overload
def adapt(__obj: Any, __proto: Any, __alt: _T) -> Any | _T: ...
def adapt(obj: Any, proto: Any, alt: _T, /) -> Any | _T: ...
def complete_statement(statement: str) -> bool: ...
if sys.version_info >= (3, 12):
@@ -247,27 +247,27 @@ else:
uri: bool = ...,
) -> Connection: ...
def enable_callback_tracebacks(__enable: bool) -> None: ...
def enable_callback_tracebacks(enable: bool, /) -> None: ...
if sys.version_info < (3, 12):
# takes a pos-or-keyword argument because there is a C wrapper
def enable_shared_cache(enable: int) -> None: ...
if sys.version_info >= (3, 10):
def register_adapter(__type: type[_T], __adapter: _Adapter[_T]) -> None: ...
def register_converter(__typename: str, __converter: _Converter) -> None: ...
def register_adapter(type: type[_T], adapter: _Adapter[_T], /) -> None: ...
def register_converter(typename: str, converter: _Converter, /) -> None: ...
else:
def register_adapter(__type: type[_T], __caster: _Adapter[_T]) -> None: ...
def register_converter(__name: str, __converter: _Converter) -> None: ...
def register_adapter(type: type[_T], caster: _Adapter[_T], /) -> None: ...
def register_converter(name: str, converter: _Converter, /) -> None: ...
class _AggregateProtocol(Protocol):
def step(self, __value: int) -> object: ...
def step(self, value: int, /) -> object: ...
def finalize(self) -> int: ...
class _SingleParamWindowAggregateClass(Protocol):
def step(self, __param: Any) -> object: ...
def inverse(self, __param: Any) -> object: ...
def step(self, param: Any, /) -> object: ...
def inverse(self, param: Any, /) -> object: ...
def value(self) -> _SqliteData: ...
def finalize(self) -> _SqliteData: ...
@@ -344,7 +344,7 @@ class Connection:
def close(self) -> None: ...
if sys.version_info >= (3, 11):
def blobopen(self, __table: str, __column: str, __row: int, *, readonly: bool = False, name: str = "main") -> Blob: ...
def blobopen(self, table: str, column: str, row: int, /, *, readonly: bool = False, name: str = "main") -> Blob: ...
def commit(self) -> None: ...
def create_aggregate(self, name: str, n_arg: int, aggregate_class: Callable[[], _AggregateProtocol]) -> None: ...
@@ -353,19 +353,19 @@ class Connection:
# for the case where num_params = 1, which is expected to be the common case.
@overload
def create_window_function(
self, __name: str, __num_params: Literal[1], __aggregate_class: Callable[[], _SingleParamWindowAggregateClass] | None
self, name: str, num_params: Literal[1], aggregate_class: Callable[[], _SingleParamWindowAggregateClass] | None, /
) -> None: ...
# And for num_params = -1, which means the aggregate must accept any number of parameters.
@overload
def create_window_function(
self, __name: str, __num_params: Literal[-1], __aggregate_class: Callable[[], _AnyParamWindowAggregateClass] | None
self, name: str, num_params: Literal[-1], aggregate_class: Callable[[], _AnyParamWindowAggregateClass] | None, /
) -> None: ...
@overload
def create_window_function(
self, __name: str, __num_params: int, __aggregate_class: Callable[[], _WindowAggregateClass] | None
self, name: str, num_params: int, aggregate_class: Callable[[], _WindowAggregateClass] | None, /
) -> None: ...
def create_collation(self, __name: str, __callback: Callable[[str, str], int | SupportsIndex] | None) -> None: ...
def create_collation(self, name: str, callback: Callable[[str, str], int | SupportsIndex] | None, /) -> None: ...
def create_function(
self, name: str, narg: int, func: Callable[..., _SqliteData] | None, *, deterministic: bool = False
) -> None: ...
@@ -373,9 +373,9 @@ class Connection:
def cursor(self, factory: None = None) -> Cursor: ...
@overload
def cursor(self, factory: Callable[[Connection], _CursorT]) -> _CursorT: ...
def execute(self, __sql: str, __parameters: _Parameters = ...) -> Cursor: ...
def executemany(self, __sql: str, __parameters: Iterable[_Parameters]) -> Cursor: ...
def executescript(self, __sql_script: str) -> Cursor: ...
def execute(self, sql: str, parameters: _Parameters = ..., /) -> Cursor: ...
def executemany(self, sql: str, parameters: Iterable[_Parameters], /) -> Cursor: ...
def executescript(self, sql_script: str, /) -> Cursor: ...
def interrupt(self) -> None: ...
def iterdump(self) -> Generator[str, None, None]: ...
def rollback(self) -> None: ...
@@ -386,8 +386,8 @@ class Connection:
def set_trace_callback(self, trace_callback: Callable[[str], object] | None) -> None: ...
# enable_load_extension and load_extension is not available on python distributions compiled
# without sqlite3 loadable extension support. see footnotes https://docs.python.org/3/library/sqlite3.html#f1
def enable_load_extension(self, __enable: bool) -> None: ...
def load_extension(self, __name: str) -> None: ...
def enable_load_extension(self, enable: bool, /) -> None: ...
def load_extension(self, name: str, /) -> None: ...
def backup(
self,
target: Connection,
@@ -398,18 +398,18 @@ class Connection:
sleep: float = 0.25,
) -> None: ...
if sys.version_info >= (3, 11):
def setlimit(self, __category: int, __limit: int) -> int: ...
def getlimit(self, __category: int) -> int: ...
def setlimit(self, category: int, limit: int, /) -> int: ...
def getlimit(self, category: int, /) -> int: ...
def serialize(self, *, name: str = "main") -> bytes: ...
def deserialize(self, __data: ReadableBuffer, *, name: str = "main") -> None: ...
def deserialize(self, data: ReadableBuffer, /, *, name: str = "main") -> None: ...
if sys.version_info >= (3, 12):
def getconfig(self, __op: int) -> bool: ...
def setconfig(self, __op: int, __enable: bool = True) -> bool: ...
def getconfig(self, op: int, /) -> bool: ...
def setconfig(self, op: int, enable: bool = True, /) -> bool: ...
def __call__(self, __sql: str) -> _Statement: ...
def __call__(self, sql: str, /) -> _Statement: ...
def __enter__(self) -> Self: ...
def __exit__(
self, __type: type[BaseException] | None, __value: BaseException | None, __traceback: TracebackType | None
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None, /
) -> Literal[False]: ...
class Cursor(Iterator[Any]):
@@ -424,18 +424,18 @@ class Cursor(Iterator[Any]):
row_factory: Callable[[Cursor, Row], object] | None
@property
def rowcount(self) -> int: ...
def __init__(self, __cursor: Connection) -> None: ...
def __init__(self, cursor: Connection, /) -> None: ...
def close(self) -> None: ...
def execute(self, __sql: str, __parameters: _Parameters = ()) -> Self: ...
def executemany(self, __sql: str, __seq_of_parameters: Iterable[_Parameters]) -> Self: ...
def executescript(self, __sql_script: str) -> Cursor: ...
def execute(self, sql: str, parameters: _Parameters = (), /) -> Self: ...
def executemany(self, sql: str, seq_of_parameters: Iterable[_Parameters], /) -> Self: ...
def executescript(self, sql_script: str, /) -> Cursor: ...
def fetchall(self) -> list[Any]: ...
def fetchmany(self, size: int | None = 1) -> list[Any]: ...
# Returns either a row (as created by the row_factory) or None, but
# putting None in the return annotation causes annoying false positives.
def fetchone(self) -> Any: ...
def setinputsizes(self, __sizes: Unused) -> None: ... # does nothing
def setoutputsize(self, __size: Unused, __column: Unused = None) -> None: ... # does nothing
def setinputsizes(self, sizes: Unused, /) -> None: ... # does nothing
def setoutputsize(self, size: Unused, column: Unused = None, /) -> None: ... # does nothing
def __iter__(self) -> Self: ...
def __next__(self) -> Any: ...
@@ -462,22 +462,22 @@ class PrepareProtocol:
class ProgrammingError(DatabaseError): ...
class Row:
def __init__(self, __cursor: Cursor, __data: tuple[Any, ...]) -> None: ...
def __init__(self, cursor: Cursor, data: tuple[Any, ...], /) -> None: ...
def keys(self) -> list[str]: ...
@overload
def __getitem__(self, __key: int | str) -> Any: ...
def __getitem__(self, key: int | str, /) -> Any: ...
@overload
def __getitem__(self, __key: slice) -> tuple[Any, ...]: ...
def __getitem__(self, key: slice, /) -> tuple[Any, ...]: ...
def __hash__(self) -> int: ...
def __iter__(self) -> Iterator[Any]: ...
def __len__(self) -> int: ...
# These return NotImplemented for anything that is not a Row.
def __eq__(self, __value: object) -> bool: ...
def __ge__(self, __value: object) -> bool: ...
def __gt__(self, __value: object) -> bool: ...
def __le__(self, __value: object) -> bool: ...
def __lt__(self, __value: object) -> bool: ...
def __ne__(self, __value: object) -> bool: ...
def __eq__(self, value: object, /) -> bool: ...
def __ge__(self, value: object, /) -> bool: ...
def __gt__(self, value: object, /) -> bool: ...
def __le__(self, value: object, /) -> bool: ...
def __lt__(self, value: object, /) -> bool: ...
def __ne__(self, value: object, /) -> bool: ...
@final
class _Statement: ...
@@ -488,13 +488,13 @@ if sys.version_info >= (3, 11):
@final
class Blob:
def close(self) -> None: ...
def read(self, __length: int = -1) -> bytes: ...
def write(self, __data: ReadableBuffer) -> None: ...
def read(self, length: int = -1, /) -> bytes: ...
def write(self, data: ReadableBuffer, /) -> None: ...
def tell(self) -> int: ...
# whence must be one of os.SEEK_SET, os.SEEK_CUR, os.SEEK_END
def seek(self, __offset: int, __origin: int = 0) -> None: ...
def seek(self, offset: int, origin: int = 0, /) -> None: ...
def __len__(self) -> int: ...
def __enter__(self) -> Self: ...
def __exit__(self, __type: object, __val: object, __tb: object) -> Literal[False]: ...
def __getitem__(self, __key: SupportsIndex | slice) -> int: ...
def __setitem__(self, __key: SupportsIndex | slice, __value: int) -> None: ...
def __exit__(self, type: object, val: object, tb: object, /) -> Literal[False]: ...
def __getitem__(self, key: SupportsIndex | slice, /) -> int: ...
def __setitem__(self, key: SupportsIndex | slice, value: int, /) -> None: ...