Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync typeshed #17081

Merged
merged 4 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,7 @@ class MemoryError(Exception): ...

class NameError(Exception):
if sys.version_info >= (3, 10):
def __init__(self, *args: object, name: str | None = ...) -> None: ...
name: str

class ReferenceError(Exception): ...
Expand Down
8 changes: 4 additions & 4 deletions mypy/typeshed/stdlib/dataclasses.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class InitVar(Generic[_T], metaclass=_InitVarMeta):
if sys.version_info >= (3, 12):
def make_dataclass(
cls_name: str,
fields: Iterable[str | tuple[str, type] | tuple[str, type, Any]],
fields: Iterable[str | tuple[str, Any] | tuple[str, Any, Any]],
*,
bases: tuple[type, ...] = (),
namespace: dict[str, Any] | None = None,
Expand All @@ -263,7 +263,7 @@ if sys.version_info >= (3, 12):
elif sys.version_info >= (3, 11):
def make_dataclass(
cls_name: str,
fields: Iterable[str | tuple[str, type] | tuple[str, type, Any]],
fields: Iterable[str | tuple[str, Any] | tuple[str, Any, Any]],
*,
bases: tuple[type, ...] = (),
namespace: dict[str, Any] | None = None,
Expand All @@ -282,7 +282,7 @@ elif sys.version_info >= (3, 11):
elif sys.version_info >= (3, 10):
def make_dataclass(
cls_name: str,
fields: Iterable[str | tuple[str, type] | tuple[str, type, Any]],
fields: Iterable[str | tuple[str, Any] | tuple[str, Any, Any]],
*,
bases: tuple[type, ...] = (),
namespace: dict[str, Any] | None = None,
Expand All @@ -300,7 +300,7 @@ elif sys.version_info >= (3, 10):
else:
def make_dataclass(
cls_name: str,
fields: Iterable[str | tuple[str, type] | tuple[str, type, Any]],
fields: Iterable[str | tuple[str, Any] | tuple[str, Any, Any]],
*,
bases: tuple[type, ...] = (),
namespace: dict[str, Any] | None = None,
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/importlib/resources/simple.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ if sys.version_info >= (3, 11):
def is_file(self) -> Literal[True]: ...
def is_dir(self) -> Literal[False]: ...
@overload
def open(self, mode: OpenTextMode = "r", *args: Incomplete, **kwargs: Incomplete) -> TextIOWrapper: ...
def open(self, mode: OpenTextMode = "r", *args, **kwargs) -> TextIOWrapper: ...
@overload
def open(self, mode: OpenBinaryMode, *args: Unused, **kwargs: Unused) -> BinaryIO: ...
@overload
def open(self, mode: str, *args: Incomplete, **kwargs: Incomplete) -> IO[Any]: ...
def open(self, mode: str, *args: Incomplete, **kwargs) -> IO[Any]: ...
def joinpath(self, name: Never) -> NoReturn: ... # type: ignore[override]

class ResourceContainer(Traversable, metaclass=abc.ABCMeta):
Expand Down
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/multiprocessing/resource_tracker.pyi
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from _typeshed import FileDescriptorOrPath, Incomplete
from _typeshed import FileDescriptorOrPath
from collections.abc import Sized

__all__ = ["ensure_running", "register", "unregister"]

class ResourceTracker:
def getfd(self) -> int | None: ...
def ensure_running(self) -> None: ...
def register(self, name: Sized, rtype: Incomplete) -> None: ...
def unregister(self, name: Sized, rtype: Incomplete) -> None: ...
def register(self, name: Sized, rtype) -> None: ...
def unregister(self, name: Sized, rtype) -> None: ...

_resource_tracker: ResourceTracker
ensure_running = _resource_tracker.ensure_running
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/multiprocessing/util.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def is_abstract_socket_namespace(address: str | bytes | None) -> bool: ...
abstract_sockets_supported: bool

def get_temp_dir() -> str: ...
def register_after_fork(obj: Incomplete, func: Callable[[Incomplete], object]) -> None: ...
def register_after_fork(obj, func: Callable[[Incomplete], object]) -> None: ...

class Finalize:
def __init__(
Expand All @@ -59,7 +59,7 @@ class Finalize:
_finalizer_registry: MutableMapping[Incomplete, Incomplete] = {},
sub_debug: Callable[..., object] = ...,
getpid: Callable[[], int] = ...,
) -> Incomplete: ...
): ...
def cancel(self) -> None: ...
def still_active(self) -> bool: ...

Expand Down
2 changes: 2 additions & 0 deletions mypy/typeshed/stdlib/pyexpat/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class XMLParserType:
def ExternalEntityParserCreate(self, context: str | None, encoding: str = ..., /) -> XMLParserType: ...
def SetParamEntityParsing(self, flag: int, /) -> int: ...
def UseForeignDTD(self, flag: bool = True, /) -> None: ...
def GetReparseDeferralEnabled(self) -> bool: ...
def SetReparseDeferralEnabled(self, enabled: bool, /) -> None: ...
@property
def intern(self) -> dict[str, str]: ...
buffer_size: int
Expand Down
8 changes: 2 additions & 6 deletions mypy/typeshed/stdlib/signal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,8 @@ else:
@property
def si_band(self) -> int: ...

if sys.version_info >= (3, 10):
def sigtimedwait(sigset: Iterable[int], timeout: float, /) -> struct_siginfo | None: ...
def sigwaitinfo(sigset: Iterable[int], /) -> struct_siginfo: ...
else:
def sigtimedwait(sigset: Iterable[int], timeout: float) -> struct_siginfo | None: ...
def sigwaitinfo(sigset: Iterable[int]) -> struct_siginfo: ...
def sigtimedwait(sigset: Iterable[int], timeout: float, /) -> struct_siginfo | None: ...
def sigwaitinfo(sigset: Iterable[int], /) -> struct_siginfo: ...

def strsignal(signalnum: _SIGNUM, /) -> str | None: ...
def valid_signals() -> set[Signals]: ...
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/tkinter/commondialog.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ class Dialog:
command: ClassVar[str | None]
master: Incomplete | None
options: Mapping[str, Incomplete]
def __init__(self, master: Incomplete | None = None, **options: Incomplete) -> None: ...
def show(self, **options: Incomplete) -> Incomplete: ...
def __init__(self, master: Incomplete | None = None, **options) -> None: ...
def show(self, **options): ...
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/tkinter/dialog.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ DIALOG_ICON: str
class Dialog(Widget):
widgetName: str
num: int
def __init__(self, master: Incomplete | None = None, cnf: Mapping[str, Any] = {}, **kw: Incomplete) -> None: ...
def __init__(self, master: Incomplete | None = None, cnf: Mapping[str, Any] = {}, **kw) -> None: ...
def destroy(self) -> None: ...
3 changes: 1 addition & 2 deletions mypy/typeshed/stdlib/tkinter/scrolledtext.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from _typeshed import Incomplete
from tkinter import Frame, Misc, Scrollbar, Text

__all__ = ["ScrolledText"]
Expand All @@ -7,4 +6,4 @@ __all__ = ["ScrolledText"]
class ScrolledText(Text):
frame: Frame
vbar: Scrollbar
def __init__(self, master: Misc | None = None, **kwargs: Incomplete) -> None: ...
def __init__(self, master: Misc | None = None, **kwargs) -> None: ...
8 changes: 4 additions & 4 deletions mypy/typeshed/stdlib/traceback.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ __all__ = [
"walk_tb",
]

_PT: TypeAlias = tuple[str, int, str, str | None]
_FrameSummaryTuple: TypeAlias = tuple[str, int, str, str | None]

def print_tb(tb: TracebackType | None, limit: int | None = None, file: SupportsWrite[str] | None = None) -> None: ...

Expand Down Expand Up @@ -80,10 +80,10 @@ def print_last(limit: int | None = None, file: SupportsWrite[str] | None = None,
def print_stack(f: FrameType | None = None, limit: int | None = None, file: SupportsWrite[str] | None = None) -> None: ...
def extract_tb(tb: TracebackType | None, limit: int | None = None) -> StackSummary: ...
def extract_stack(f: FrameType | None = None, limit: int | None = None) -> StackSummary: ...
def format_list(extracted_list: list[FrameSummary]) -> list[str]: ...
def format_list(extracted_list: Iterable[FrameSummary | _FrameSummaryTuple]) -> list[str]: ...

# undocumented
def print_list(extracted_list: list[FrameSummary], file: SupportsWrite[str] | None = None) -> None: ...
def print_list(extracted_list: Iterable[FrameSummary | _FrameSummaryTuple], file: SupportsWrite[str] | None = None) -> None: ...

if sys.version_info >= (3, 10):
@overload
Expand Down Expand Up @@ -255,7 +255,7 @@ class StackSummary(list[FrameSummary]):
capture_locals: bool = False,
) -> StackSummary: ...
@classmethod
def from_list(cls, a_list: Iterable[FrameSummary | _PT]) -> StackSummary: ...
def from_list(cls, a_list: Iterable[FrameSummary | _FrameSummaryTuple]) -> StackSummary: ...
if sys.version_info >= (3, 11):
def format_frame_summary(self, frame_summary: FrameSummary) -> str: ...

Expand Down
10 changes: 5 additions & 5 deletions mypy/typeshed/stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import collections # noqa: F401 # pyright: ignore
import sys
import typing_extensions
from _collections_abc import dict_items, dict_keys, dict_values
from _typeshed import IdentityFunction, Incomplete, ReadableBuffer, SupportsKeysAndGetItem
from _typeshed import IdentityFunction, ReadableBuffer, SupportsKeysAndGetItem
from abc import ABCMeta, abstractmethod
from contextlib import AbstractAsyncContextManager, AbstractContextManager
from re import Match as Match, Pattern as Pattern
Expand Down Expand Up @@ -170,7 +170,7 @@ class TypeVar:
def __or__(self, right: Any) -> _SpecialForm: ...
def __ror__(self, left: Any) -> _SpecialForm: ...
if sys.version_info >= (3, 11):
def __typing_subst__(self, arg: Incomplete) -> Incomplete: ...
def __typing_subst__(self, arg): ...

# Used for an undocumented mypy feature. Does not exist at runtime.
_promote = object()
Expand Down Expand Up @@ -221,7 +221,7 @@ if sys.version_info >= (3, 11):
def __init__(self, name: str) -> None: ...
def __iter__(self) -> Any: ...
def __typing_subst__(self, arg: Never) -> Never: ...
def __typing_prepare_subst__(self, alias: Incomplete, args: Incomplete) -> Incomplete: ...
def __typing_prepare_subst__(self, alias, args): ...

if sys.version_info >= (3, 10):
@final
Expand Down Expand Up @@ -270,8 +270,8 @@ if sys.version_info >= (3, 10):
@property
def kwargs(self) -> ParamSpecKwargs: ...
if sys.version_info >= (3, 11):
def __typing_subst__(self, arg: Incomplete) -> Incomplete: ...
def __typing_prepare_subst__(self, alias: Incomplete, args: Incomplete) -> Incomplete: ...
def __typing_subst__(self, arg): ...
def __typing_prepare_subst__(self, alias, args): ...

def __or__(self, right: Any) -> _SpecialForm: ...
def __ror__(self, left: Any) -> _SpecialForm: ...
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/typing_extensions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import abc
import sys
import typing
from _collections_abc import dict_items, dict_keys, dict_values
from _typeshed import IdentityFunction, Incomplete
from _typeshed import IdentityFunction
from typing import ( # noqa: Y022,Y037,Y038,Y039
IO as IO,
TYPE_CHECKING as TYPE_CHECKING,
Expand Down Expand Up @@ -413,7 +413,7 @@ class TypeVar:
def __or__(self, right: Any) -> _SpecialForm: ...
def __ror__(self, left: Any) -> _SpecialForm: ...
if sys.version_info >= (3, 11):
def __typing_subst__(self, arg: Incomplete) -> Incomplete: ...
def __typing_subst__(self, arg): ...

@final
class ParamSpec:
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/xml/dom/xmlbuilder.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class DOMBuilder:
def supportsFeature(self, name: str) -> bool: ...
def canSetFeature(self, name: str, state: int) -> bool: ...
# getFeature could return any attribute from an instance of `Options`
def getFeature(self, name: str) -> Incomplete: ...
def getFeature(self, name: str): ...
def parseURI(self, uri: str) -> ExpatBuilder | ExpatBuilderNS: ...
def parse(self, input: DOMInputSource) -> ExpatBuilder | ExpatBuilderNS: ...
# `input` and `cnode` argtypes for `parseWithContext` are unknowable
Expand Down
2 changes: 2 additions & 0 deletions mypy/typeshed/stdlib/xml/etree/ElementTree.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ class XMLPullParser:
# Second element in the tuple could be `Element`, `tuple[str, str]` or `None`.
# Use `Any` to avoid false-positive errors.
def read_events(self) -> Iterator[tuple[str, Any]]: ...
def flush(self) -> None: ...

def XML(text: str | ReadableBuffer, parser: XMLParser | None = None) -> Element: ...
def XMLID(text: str | ReadableBuffer, parser: XMLParser | None = None) -> tuple[Element, dict[str, Element]]: ...
Expand Down Expand Up @@ -323,3 +324,4 @@ class XMLParser:
def __init__(self, *, target: Any = ..., encoding: str | None = ...) -> None: ...
def close(self) -> Any: ...
def feed(self, data: str | ReadableBuffer, /) -> None: ...
def flush(self) -> None: ...
Loading