mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-16 00:37:10 +08:00
stdlib: more deprecations (#11009)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
@@ -3,7 +3,7 @@ from _typeshed import sentinel
|
||||
from collections.abc import Callable, Generator, Iterable, Sequence
|
||||
from re import Pattern
|
||||
from typing import IO, Any, Generic, Literal, NewType, NoReturn, Protocol, TypeVar, overload
|
||||
from typing_extensions import Self, TypeAlias
|
||||
from typing_extensions import Self, TypeAlias, deprecated
|
||||
|
||||
__all__ = [
|
||||
"ArgumentParser",
|
||||
@@ -339,11 +339,23 @@ class Action(_AttributeHolder):
|
||||
|
||||
if sys.version_info >= (3, 12):
|
||||
class BooleanOptionalAction(Action):
|
||||
@overload
|
||||
def __init__(
|
||||
self,
|
||||
option_strings: Sequence[str],
|
||||
dest: str,
|
||||
default: _T | str | None = None,
|
||||
default: bool | None = None,
|
||||
*,
|
||||
required: bool = False,
|
||||
help: str | None = None,
|
||||
) -> None: ...
|
||||
@overload
|
||||
@deprecated("The `type`, `choices`, and `metavar` parameters are ignored and will be removed in Python 3.14.")
|
||||
def __init__(
|
||||
self,
|
||||
option_strings: Sequence[str],
|
||||
dest: str,
|
||||
default: _T | bool | None = None,
|
||||
type: Callable[[str], _T] | FileType | None = sentinel,
|
||||
choices: Iterable[_T] | None = sentinel,
|
||||
required: bool = False,
|
||||
@@ -353,11 +365,23 @@ if sys.version_info >= (3, 12):
|
||||
|
||||
elif sys.version_info >= (3, 9):
|
||||
class BooleanOptionalAction(Action):
|
||||
@overload
|
||||
def __init__(
|
||||
self,
|
||||
option_strings: Sequence[str],
|
||||
dest: str,
|
||||
default: _T | str | None = None,
|
||||
default: bool | None = None,
|
||||
*,
|
||||
required: bool = False,
|
||||
help: str | None = None,
|
||||
) -> None: ...
|
||||
@overload
|
||||
@deprecated("The `type`, `choices`, and `metavar` parameters are ignored and will be removed in Python 3.14.")
|
||||
def __init__(
|
||||
self,
|
||||
option_strings: Sequence[str],
|
||||
dest: str,
|
||||
default: _T | bool | None = None,
|
||||
type: Callable[[str], _T] | FileType | None = None,
|
||||
choices: Iterable[_T] | None = None,
|
||||
required: bool = False,
|
||||
|
||||
@@ -543,10 +543,18 @@ class AbstractEventLoopPolicy:
|
||||
@abstractmethod
|
||||
def new_event_loop(self) -> AbstractEventLoop: ...
|
||||
# Child processes handling (Unix only).
|
||||
@abstractmethod
|
||||
def get_child_watcher(self) -> AbstractChildWatcher: ...
|
||||
@abstractmethod
|
||||
def set_child_watcher(self, watcher: AbstractChildWatcher) -> None: ...
|
||||
if sys.version_info >= (3, 12):
|
||||
@abstractmethod
|
||||
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
|
||||
def get_child_watcher(self) -> AbstractChildWatcher: ...
|
||||
@abstractmethod
|
||||
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
|
||||
def set_child_watcher(self, watcher: AbstractChildWatcher) -> None: ...
|
||||
else:
|
||||
@abstractmethod
|
||||
def get_child_watcher(self) -> AbstractChildWatcher: ...
|
||||
@abstractmethod
|
||||
def set_child_watcher(self, watcher: AbstractChildWatcher) -> None: ...
|
||||
|
||||
class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy, metaclass=ABCMeta):
|
||||
def get_event_loop(self) -> AbstractEventLoop: ...
|
||||
|
||||
@@ -2,7 +2,7 @@ import sys
|
||||
from abc import abstractmethod
|
||||
from time import struct_time
|
||||
from typing import ClassVar, Literal, NamedTuple, NoReturn, SupportsIndex, TypeVar, final, overload
|
||||
from typing_extensions import Self, TypeAlias
|
||||
from typing_extensions import Self, TypeAlias, deprecated
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
__all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo", "MINYEAR", "MAXYEAR", "UTC")
|
||||
@@ -251,10 +251,12 @@ class datetime(date):
|
||||
def fromtimestamp(cls, __timestamp: float, tz: _TzInfo | None = ...) -> Self: ...
|
||||
|
||||
@classmethod
|
||||
@deprecated("Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .fromtimestamp(datetime.UTC)")
|
||||
def utcfromtimestamp(cls, __t: float) -> Self: ...
|
||||
@classmethod
|
||||
def now(cls, tz: _TzInfo | None = None) -> Self: ...
|
||||
@classmethod
|
||||
@deprecated("Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.UTC)")
|
||||
def utcnow(cls) -> Self: ...
|
||||
@classmethod
|
||||
def combine(cls, date: _Date, time: _Time, tzinfo: _TzInfo | None = ...) -> Self: ...
|
||||
|
||||
@@ -4,7 +4,7 @@ from _typeshed import Unused
|
||||
from email import _ParamType
|
||||
from email.charset import Charset
|
||||
from typing import overload
|
||||
from typing_extensions import TypeAlias
|
||||
from typing_extensions import TypeAlias, deprecated
|
||||
|
||||
__all__ = [
|
||||
"collapse_rfc2231_value",
|
||||
@@ -54,6 +54,10 @@ def formatdate(timeval: float | None = None, localtime: bool = False, usegmt: bo
|
||||
def format_datetime(dt: datetime.datetime, usegmt: bool = False) -> str: ...
|
||||
|
||||
if sys.version_info >= (3, 12):
|
||||
@overload
|
||||
def localtime(dt: datetime.datetime | None = None) -> datetime.datetime: ...
|
||||
@overload
|
||||
@deprecated("The `isdst` parameter does nothing and will be removed in Python 3.14.")
|
||||
def localtime(dt: datetime.datetime | None = None, isdst: Unused = None) -> datetime.datetime: ...
|
||||
|
||||
else:
|
||||
|
||||
@@ -40,7 +40,7 @@ from typing import (
|
||||
overload,
|
||||
runtime_checkable,
|
||||
)
|
||||
from typing_extensions import Self, TypeAlias, Unpack
|
||||
from typing_extensions import Self, TypeAlias, Unpack, deprecated
|
||||
|
||||
from . import path as _path
|
||||
|
||||
@@ -361,8 +361,16 @@ class stat_result(structseq[float], tuple[int, int, int, int, int, int, int, flo
|
||||
@property
|
||||
def st_mtime(self) -> float: ... # time of most recent content modification,
|
||||
# platform dependent (time of most recent metadata change on Unix, or the time of creation on Windows)
|
||||
@property
|
||||
def st_ctime(self) -> float: ...
|
||||
if sys.version_info >= (3, 12) and sys.platform == "win32":
|
||||
@property
|
||||
@deprecated(
|
||||
"Use st_birthtime instead to retrieve the file creation time. In the future, this property will contain the last metadata change time."
|
||||
)
|
||||
def st_ctime(self) -> float: ...
|
||||
else:
|
||||
@property
|
||||
def st_ctime(self) -> float: ...
|
||||
|
||||
@property
|
||||
def st_atime_ns(self) -> int: ... # time of most recent access, in nanoseconds
|
||||
@property
|
||||
|
||||
@@ -4,7 +4,7 @@ from _typeshed import BytesPath, FileDescriptorOrPath, StrOrBytesPath, StrPath,
|
||||
from collections.abc import Callable, Iterable, Sequence
|
||||
from tarfile import _TarfileFilter
|
||||
from typing import Any, AnyStr, NamedTuple, Protocol, TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
from typing_extensions import TypeAlias, deprecated
|
||||
|
||||
__all__ = [
|
||||
"copyfileobj",
|
||||
@@ -78,24 +78,20 @@ class _RmtreeType(Protocol):
|
||||
avoids_symlink_attacks: bool
|
||||
if sys.version_info >= (3, 12):
|
||||
@overload
|
||||
def __call__(self, path: StrOrBytesPath, ignore_errors: bool = False, *, dir_fd: int | None = None) -> None: ...
|
||||
@overload
|
||||
@deprecated("The `onerror` parameter is deprecated and will be removed in Python 3.14. Use `onexc` instead.")
|
||||
def __call__(
|
||||
self,
|
||||
path: StrOrBytesPath,
|
||||
ignore_errors: bool = False,
|
||||
onerror: _OnErrorCallback | None = None,
|
||||
*,
|
||||
onexc: None = None,
|
||||
dir_fd: int | None = None,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __call__(
|
||||
self,
|
||||
path: StrOrBytesPath,
|
||||
ignore_errors: bool = False,
|
||||
onerror: None = None,
|
||||
*,
|
||||
onexc: _OnExcCallback,
|
||||
dir_fd: int | None = None,
|
||||
self, path: StrOrBytesPath, ignore_errors: bool = False, *, onexc: _OnExcCallback, dir_fd: int | None = None
|
||||
) -> None: ...
|
||||
elif sys.version_info >= (3, 11):
|
||||
def __call__(
|
||||
|
||||
@@ -7,7 +7,7 @@ from collections.abc import Callable, Iterable, Iterator, Mapping
|
||||
from gzip import _ReadableFileobj as _GzipReadableFileobj, _WritableFileobj as _GzipWritableFileobj
|
||||
from types import TracebackType
|
||||
from typing import IO, ClassVar, Literal, Protocol, overload
|
||||
from typing_extensions import Self, TypeAlias
|
||||
from typing_extensions import Self, TypeAlias, deprecated
|
||||
|
||||
__all__ = [
|
||||
"TarFile",
|
||||
@@ -292,14 +292,31 @@ class TarFile:
|
||||
def getnames(self) -> _list[str]: ...
|
||||
def list(self, verbose: bool = True, *, members: _list[TarInfo] | None = None) -> None: ...
|
||||
def next(self) -> TarInfo | None: ...
|
||||
@overload
|
||||
@deprecated(
|
||||
"Extracting tar archives without specifying `filter` is deprecated until Python 3.14, when 'data' filter will become the default."
|
||||
)
|
||||
def extractall(
|
||||
self,
|
||||
path: StrOrBytesPath = ".",
|
||||
members: Iterable[TarInfo] | None = None,
|
||||
*,
|
||||
numeric_owner: bool = False,
|
||||
filter: _TarfileFilter | None = ...,
|
||||
filter: None = ...,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def extractall(
|
||||
self,
|
||||
path: StrOrBytesPath = ".",
|
||||
members: Iterable[TarInfo] | None = None,
|
||||
*,
|
||||
numeric_owner: bool = False,
|
||||
filter: _TarfileFilter,
|
||||
) -> None: ...
|
||||
@overload
|
||||
@deprecated(
|
||||
"Extracting tar archives without specifying `filter` is deprecated until Python 3.14, when 'data' filter will become the default."
|
||||
)
|
||||
def extract(
|
||||
self,
|
||||
member: str | TarInfo,
|
||||
@@ -307,7 +324,17 @@ class TarFile:
|
||||
set_attrs: bool = True,
|
||||
*,
|
||||
numeric_owner: bool = False,
|
||||
filter: _TarfileFilter | None = ...,
|
||||
filter: None = ...,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def extract(
|
||||
self,
|
||||
member: str | TarInfo,
|
||||
path: StrOrBytesPath = "",
|
||||
set_attrs: bool = True,
|
||||
*,
|
||||
numeric_owner: bool = False,
|
||||
filter: _TarfileFilter,
|
||||
) -> None: ...
|
||||
def _extract_member(
|
||||
self, tarinfo: TarInfo, targetpath: str, set_attrs: bool = True, numeric_owner: bool = False
|
||||
|
||||
@@ -17,7 +17,7 @@ from importlib.machinery import ModuleSpec
|
||||
|
||||
# pytype crashes if types.MappingProxyType inherits from collections.abc.Mapping instead of typing.Mapping
|
||||
from typing import Any, ClassVar, Literal, Mapping, Protocol, TypeVar, final, overload # noqa: Y022
|
||||
from typing_extensions import ParamSpec, Self, TypeVarTuple
|
||||
from typing_extensions import ParamSpec, Self, TypeVarTuple, deprecated
|
||||
|
||||
__all__ = [
|
||||
"FunctionType",
|
||||
@@ -138,8 +138,14 @@ class CodeType:
|
||||
def co_name(self) -> str: ...
|
||||
@property
|
||||
def co_firstlineno(self) -> int: ...
|
||||
@property
|
||||
def co_lnotab(self) -> bytes: ...
|
||||
if sys.version_info >= (3, 10):
|
||||
@property
|
||||
@deprecated("Will be removed in Python 3.14. Use the co_lines() method instead.")
|
||||
def co_lnotab(self) -> bytes: ...
|
||||
else:
|
||||
@property
|
||||
def co_lnotab(self) -> bytes: ...
|
||||
|
||||
@property
|
||||
def co_freevars(self) -> tuple[str, ...]: ...
|
||||
@property
|
||||
|
||||
@@ -3,7 +3,7 @@ from _collections_abc import dict_keys
|
||||
from _typeshed import FileDescriptorOrPath, ReadableBuffer, SupportsRead, SupportsWrite
|
||||
from collections.abc import Callable, Generator, ItemsView, Iterable, Iterator, Mapping, Sequence
|
||||
from typing import Any, Literal, SupportsIndex, TypeVar, overload
|
||||
from typing_extensions import TypeAlias, TypeGuard
|
||||
from typing_extensions import TypeAlias, TypeGuard, deprecated
|
||||
|
||||
__all__ = [
|
||||
"C14NWriterTarget",
|
||||
@@ -121,6 +121,10 @@ class Element:
|
||||
def __setitem__(self, __key: SupportsIndex, __value: Element) -> None: ...
|
||||
@overload
|
||||
def __setitem__(self, __key: slice, __value: Iterable[Element]) -> None: ...
|
||||
|
||||
# Doesn't really exist in earlier versions, where __len__ is called implicitly instead
|
||||
@deprecated("Testing an element's truth value is deprecated.")
|
||||
def __bool__(self) -> bool: ...
|
||||
if sys.version_info < (3, 9):
|
||||
def getchildren(self) -> list[Element]: ...
|
||||
def getiterator(self, tag: str | None = None) -> list[Element]: ...
|
||||
|
||||
@@ -25,6 +25,9 @@ typing._SpecialForm.__mro_entries__
|
||||
weakref.ProxyType.__reversed__ # Doesn't really exist
|
||||
builtins.ellipsis # type is not exposed anywhere
|
||||
|
||||
xml.etree.ElementTree.Element.__bool__ # Doesn't really exist; see comments in stub
|
||||
xml.etree.cElementTree.Element.__bool__ # Doesn't really exist; see comments in stub
|
||||
|
||||
# Runtime definition of protocol is incorrect
|
||||
importlib.metadata._meta.SimplePath.__truediv__
|
||||
importlib.metadata._meta.SimplePath.joinpath
|
||||
|
||||
@@ -18,6 +18,9 @@ tkinter._VersionInfoType.__doc__
|
||||
typing.NewType.__mro_entries__
|
||||
builtins.ellipsis # type is not exposed anywhere
|
||||
|
||||
xml.etree.ElementTree.Element.__bool__ # Doesn't really exist; see comments in stub
|
||||
xml.etree.cElementTree.Element.__bool__ # Doesn't really exist; see comments in stub
|
||||
|
||||
# Runtime definition of protocol is incorrect
|
||||
importlib.metadata._meta.SimplePath.__truediv__
|
||||
importlib.metadata._meta.SimplePath.joinpath
|
||||
|
||||
@@ -52,6 +52,9 @@ xml.etree.ElementTree.TreeBuilder.start # Discrepancy between Python and C modu
|
||||
xml.etree.cElementTree.TreeBuilder.start # bpo-39495
|
||||
xxsubtype # module missing from the stubs
|
||||
|
||||
xml.etree.ElementTree.Element.__bool__ # Doesn't really exist; see comments in stub
|
||||
xml.etree.cElementTree.Element.__bool__ # Doesn't really exist; see comments in stub
|
||||
|
||||
# Exist at runtime for internal reasons, no need to put them in the stub
|
||||
typing_extensions\.TypeAliasType\.__call__
|
||||
typing_extensions\.TypeAliasType\.__init_subclass__
|
||||
|
||||
@@ -39,6 +39,9 @@ types.GenericAlias.__call__ # Would be complicated to fix properly, Any could s
|
||||
weakref.ProxyType.__reversed__ # Doesn't really exist
|
||||
xxsubtype # module missing from the stubs
|
||||
|
||||
xml.etree.ElementTree.Element.__bool__ # Doesn't really exist; see comments in stub
|
||||
xml.etree.cElementTree.Element.__bool__ # Doesn't really exist; see comments in stub
|
||||
|
||||
# Exist at runtime for internal reasons, no need to put them in the stub
|
||||
typing_extensions\.TypeAliasType\.__call__
|
||||
typing_extensions\.TypeAliasType\.__init_subclass__
|
||||
|
||||
Reference in New Issue
Block a user