Skip to content

Commit

Permalink
Sync Typeshed (for 1.9 release) (#16844)
Browse files Browse the repository at this point in the history
Co-authored-by: Shantanu <[email protected]>
Co-authored-by: AlexWaygood <[email protected]>
  • Loading branch information
3 people authored Feb 2, 2024
1 parent ba90dc4 commit 67c3969
Show file tree
Hide file tree
Showing 261 changed files with 2,887 additions and 4,617 deletions.
1 change: 0 additions & 1 deletion mypy/typeshed/stdlib/VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ linecache: 3.0-
locale: 3.0-
logging: 3.0-
lzma: 3.3-
macpath: 3.0-3.7
mailbox: 3.0-
mailcap: 3.0-3.12
marshal: 3.0-
Expand Down
69 changes: 23 additions & 46 deletions mypy/typeshed/stdlib/_ast.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import sys
import typing_extensions
from typing import Any, ClassVar
from typing_extensions import Literal
from typing import Any, ClassVar, Literal

PyCF_ONLY_AST: Literal[1024]
if sys.version_info >= (3, 8):
PyCF_TYPE_COMMENTS: Literal[4096]
PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]
PyCF_TYPE_COMMENTS: Literal[4096]
PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]

_Identifier: typing_extensions.TypeAlias = str

Expand All @@ -19,33 +17,29 @@ class AST:
# TODO: Not all nodes have all of the following attributes
lineno: int
col_offset: int
if sys.version_info >= (3, 8):
end_lineno: int | None
end_col_offset: int | None
type_comment: str | None
end_lineno: int | None
end_col_offset: int | None
type_comment: str | None

class mod(AST): ...
class type_ignore(AST): ...

if sys.version_info >= (3, 8):
class type_ignore(AST): ...

class TypeIgnore(type_ignore):
if sys.version_info >= (3, 10):
__match_args__ = ("lineno", "tag")
tag: str
class TypeIgnore(type_ignore):
if sys.version_info >= (3, 10):
__match_args__ = ("lineno", "tag")
tag: str

class FunctionType(mod):
if sys.version_info >= (3, 10):
__match_args__ = ("argtypes", "returns")
argtypes: list[expr]
returns: expr
class FunctionType(mod):
if sys.version_info >= (3, 10):
__match_args__ = ("argtypes", "returns")
argtypes: list[expr]
returns: expr

class Module(mod):
if sys.version_info >= (3, 10):
__match_args__ = ("body", "type_ignores")
body: list[stmt]
if sys.version_info >= (3, 8):
type_ignores: list[TypeIgnore]
type_ignores: list[TypeIgnore]

class Interactive(mod):
if sys.version_info >= (3, 10):
Expand Down Expand Up @@ -340,21 +334,6 @@ class JoinedStr(expr):
__match_args__ = ("values",)
values: list[expr]

if sys.version_info < (3, 8):
class Num(expr): # Deprecated in 3.8; use Constant
n: int | float | complex

class Str(expr): # Deprecated in 3.8; use Constant
s: str

class Bytes(expr): # Deprecated in 3.8; use Constant
s: bytes

class NameConstant(expr): # Deprecated in 3.8; use Constant
value: Any

class Ellipsis(expr): ... # Deprecated in 3.8; use Constant

class Constant(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("value", "kind")
Expand All @@ -364,12 +343,11 @@ class Constant(expr):
s: Any
n: int | float | complex

if sys.version_info >= (3, 8):
class NamedExpr(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("target", "value")
target: Name
value: expr
class NamedExpr(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("target", "value")
target: Name
value: expr

class Attribute(expr):
if sys.version_info >= (3, 10):
Expand Down Expand Up @@ -498,8 +476,7 @@ class ExceptHandler(excepthandler):
class arguments(AST):
if sys.version_info >= (3, 10):
__match_args__ = ("posonlyargs", "args", "vararg", "kwonlyargs", "kw_defaults", "kwarg", "defaults")
if sys.version_info >= (3, 8):
posonlyargs: list[arg]
posonlyargs: list[arg]
args: list[arg]
vararg: arg | None
kwonlyargs: list[arg]
Expand Down
9 changes: 2 additions & 7 deletions mypy/typeshed/stdlib/_codecs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import codecs
import sys
from _typeshed import ReadableBuffer
from collections.abc import Callable
from typing import overload
from typing_extensions import Literal, TypeAlias
from typing import Literal, overload
from typing_extensions import TypeAlias

# This type is not exposed; it is defined in unicodeobject.c
class _EncodingMap:
Expand Down Expand Up @@ -99,11 +99,6 @@ else:
def unicode_escape_decode(__data: str | ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...

def unicode_escape_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...

if sys.version_info < (3, 8):
def unicode_internal_decode(__obj: str | ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...
def unicode_internal_encode(__obj: str | ReadableBuffer, __errors: str | None = None) -> tuple[bytes, int]: ...

def utf_16_be_decode(__data: ReadableBuffer, __errors: str | None = None, __final: bool = False) -> tuple[str, int]: ...
def utf_16_be_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def utf_16_decode(__data: ReadableBuffer, __errors: str | None = None, __final: bool = False) -> tuple[str, int]: ...
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_collections_abc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ from typing import ( # noqa: Y022,Y038,Y057
Sized as Sized,
TypeVar,
ValuesView as ValuesView,
final,
runtime_checkable,
)
from typing_extensions import final

__all__ = [
"Awaitable",
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_csv.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import sys
from _typeshed import SupportsWrite
from collections.abc import Iterable, Iterator
from typing import Any
from typing_extensions import Final, Literal, TypeAlias
from typing import Any, Final, Literal
from typing_extensions import TypeAlias

__version__: Final[str]

Expand Down
4 changes: 1 addition & 3 deletions mypy/typeshed/stdlib/_ctypes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sys
from _typeshed import ReadableBuffer, WriteableBuffer
from abc import abstractmethod
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from ctypes import CDLL
from ctypes import CDLL, ArgumentError as ArgumentError
from typing import Any, ClassVar, Generic, TypeVar, overload
from typing_extensions import Self, TypeAlias

Expand Down Expand Up @@ -197,8 +197,6 @@ class Array(_CData, Generic[_CT]):
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...

class ArgumentError(Exception): ...

def addressof(obj: _CData) -> int: ...
def alignment(obj_or_type: _CData | type[_CData]) -> int: ...
def get_errno() -> int: ...
Expand Down
18 changes: 9 additions & 9 deletions mypy/typeshed/stdlib/_curses.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from _typeshed import ReadOnlyBuffer, SupportsRead
from typing import IO, Any, NamedTuple, overload
from typing_extensions import TypeAlias, final
from typing import IO, Any, NamedTuple, final, overload
from typing_extensions import TypeAlias

if sys.platform != "win32":
# Handled by PyCurses_ConvertToChtype in _cursesmodule.c.
Expand Down Expand Up @@ -548,10 +548,10 @@ if sys.platform != "win32":
def vline(self, ch: _ChType, n: int) -> None: ...
@overload
def vline(self, y: int, x: int, ch: _ChType, n: int) -> None: ...
if sys.version_info >= (3, 8):
class _ncurses_version(NamedTuple):
major: int
minor: int
patch: int
ncurses_version: _ncurses_version
window = _CursesWindow # undocumented

class _ncurses_version(NamedTuple):
major: int
minor: int
patch: int
ncurses_version: _ncurses_version
window = _CursesWindow # undocumented
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_decimal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import numbers
import sys
from collections.abc import Container, Sequence
from types import TracebackType
from typing import Any, ClassVar, NamedTuple, overload
from typing_extensions import Final, Literal, Self, TypeAlias
from typing import Any, ClassVar, Final, Literal, NamedTuple, overload
from typing_extensions import Self, TypeAlias

_Decimal: TypeAlias = Decimal | int
_DecimalNew: TypeAlias = Decimal | float | str | tuple[int, Sequence[int], int]
Expand Down
19 changes: 7 additions & 12 deletions mypy/typeshed/stdlib/_dummy_threading.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
from _thread import _excepthook, _ExceptHookArgs
from _typeshed import ProfileFunction, TraceFunction
from collections.abc import Callable, Iterable, Mapping
from types import TracebackType
Expand Down Expand Up @@ -28,11 +29,10 @@ __all__ = [
"settrace",
"local",
"stack_size",
"ExceptHookArgs",
"excepthook",
]

if sys.version_info >= (3, 8):
__all__ += ["ExceptHookArgs", "excepthook"]

def active_count() -> int: ...
def current_thread() -> Thread: ...
def currentThread() -> Thread: ...
Expand Down Expand Up @@ -72,10 +72,8 @@ class Thread:
def join(self, timeout: float | None = None) -> None: ...
def getName(self) -> str: ...
def setName(self, name: str) -> None: ...
if sys.version_info >= (3, 8):
@property
def native_id(self) -> int | None: ... # only available on some platforms

@property
def native_id(self) -> int | None: ... # only available on some platforms
def is_alive(self) -> bool: ...
if sys.version_info < (3, 9):
def isAlive(self) -> bool: ...
Expand Down Expand Up @@ -138,11 +136,8 @@ class Event:
def clear(self) -> None: ...
def wait(self, timeout: float | None = None) -> bool: ...

if sys.version_info >= (3, 8):
from _thread import _excepthook, _ExceptHookArgs

excepthook = _excepthook
ExceptHookArgs = _ExceptHookArgs
excepthook = _excepthook
ExceptHookArgs = _ExceptHookArgs

class Timer(Thread):
def __init__(
Expand Down
3 changes: 1 addition & 2 deletions mypy/typeshed/stdlib/_heapq.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import Any, TypeVar
from typing_extensions import Final
from typing import Any, Final, TypeVar

_T = TypeVar("_T")

Expand Down
3 changes: 1 addition & 2 deletions mypy/typeshed/stdlib/_json.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from collections.abc import Callable
from typing import Any
from typing_extensions import final
from typing import Any, final

@final
class make_encoder:
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_operator.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import sys
from _typeshed import SupportsGetItem
from collections.abc import Callable, Container, Iterable, MutableMapping, MutableSequence, Sequence
from typing import Any, AnyStr, Generic, Protocol, SupportsAbs, TypeVar, overload
from typing_extensions import ParamSpec, SupportsIndex, TypeAlias, TypeVarTuple, Unpack, final
from typing import Any, AnyStr, Generic, Protocol, SupportsAbs, SupportsIndex, TypeVar, final, overload
from typing_extensions import ParamSpec, TypeAlias, TypeVarTuple, Unpack

_R = TypeVar("_R")
_T = TypeVar("_T")
Expand Down
9 changes: 1 addition & 8 deletions mypy/typeshed/stdlib/_osx_support.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
from collections.abc import Iterable, Sequence
from typing import TypeVar

Expand All @@ -13,13 +12,7 @@ _COMPILER_CONFIG_VARS: tuple[str, ...] # undocumented
_INITPRE: str # undocumented

def _find_executable(executable: str, path: str | None = None) -> str | None: ... # undocumented

if sys.version_info >= (3, 8):
def _read_output(commandstring: str, capture_stderr: bool = False) -> str | None: ... # undocumented

else:
def _read_output(commandstring: str) -> str | None: ... # undocumented

def _read_output(commandstring: str, capture_stderr: bool = False) -> str | None: ... # undocumented
def _find_build_tool(toolname: str) -> str: ... # undocumented

_SYSTEM_VERSION: str | None # undocumented
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_posixsubprocess.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from _typeshed import StrOrBytesPath
from collections.abc import Callable, Sequence
from typing_extensions import SupportsIndex
from typing import SupportsIndex

if sys.platform != "win32":
def cloexec_pipe() -> tuple[int, int]: ...
Expand Down
3 changes: 1 addition & 2 deletions mypy/typeshed/stdlib/_sitebuiltins.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from collections.abc import Iterable
from typing import ClassVar, NoReturn
from typing_extensions import Literal
from typing import ClassVar, Literal, NoReturn

class Quitter:
name: str
Expand Down
Loading

0 comments on commit 67c3969

Please sign in to comment.