Skip to content
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
51 changes: 51 additions & 0 deletions stdlib/unittest/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,55 @@ if sys.version_info >= (3, 8):

from .case import addModuleCleanup as addModuleCleanup

__all__ = [
"TestResult",
"TestCase",
"IsolatedAsyncioTestCase",
"TestSuite",
"TextTestRunner",
"TestLoader",
"FunctionTestCase",
"main",
"defaultTestLoader",
"SkipTest",
"skip",
"skipIf",
"skipUnless",
"expectedFailure",
"TextTestResult",
"installHandler",
"registerResult",
"removeResult",
"removeHandler",
"addModuleCleanup",
"getTestCaseNames",
"makeSuite",
"findTestCases",
]

else:
__all__ = [
"TestResult",
"TestCase",
"TestSuite",
"TextTestRunner",
"TestLoader",
"FunctionTestCase",
"main",
"defaultTestLoader",
"SkipTest",
"skip",
"skipIf",
"skipUnless",
"expectedFailure",
"TextTestResult",
"installHandler",
"registerResult",
"removeResult",
"removeHandler",
"getTestCaseNames",
"makeSuite",
"findTestCases",
]

def load_tests(loader: TestLoader, tests: TestSuite, pattern: str | None) -> TestSuite: ...
2 changes: 1 addition & 1 deletion stdlib/urllib/error.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from email.message import Message
from typing import IO
from urllib.response import addinfourl

# Stubs for urllib.error
__all__ = ["URLError", "HTTPError", "ContentTooShortError"]

class URLError(IOError):
reason: str | BaseException
Expand Down
24 changes: 24 additions & 0 deletions stdlib/urllib/parse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@ from typing import Any, AnyStr, Callable, Generic, Mapping, NamedTuple, Sequence
if sys.version_info >= (3, 9):
from types import GenericAlias

__all__ = [
"urlparse",
"urlunparse",
"urljoin",
"urldefrag",
"urlsplit",
"urlunsplit",
"urlencode",
"parse_qs",
"parse_qsl",
"quote",
"quote_plus",
"quote_from_bytes",
"unquote",
"unquote_plus",
"unquote_to_bytes",
"DefragResult",
"ParseResult",
"SplitResult",
"DefragResultBytes",
"ParseResultBytes",
"SplitResultBytes",
]

_Str = Union[bytes, str]

uses_relative: list[str]
Expand Down
37 changes: 37 additions & 0 deletions stdlib/urllib/request.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,43 @@ from typing import IO, Any, Callable, ClassVar, Iterable, Mapping, MutableMappin
from urllib.error import HTTPError
from urllib.response import addclosehook, addinfourl

__all__ = [
"Request",
"OpenerDirector",
"BaseHandler",
"HTTPDefaultErrorHandler",
"HTTPRedirectHandler",
"HTTPCookieProcessor",
"ProxyHandler",
"HTTPPasswordMgr",
"HTTPPasswordMgrWithDefaultRealm",
"HTTPPasswordMgrWithPriorAuth",
"AbstractBasicAuthHandler",
"HTTPBasicAuthHandler",
"ProxyBasicAuthHandler",
"AbstractDigestAuthHandler",
"HTTPDigestAuthHandler",
"ProxyDigestAuthHandler",
"HTTPHandler",
"FileHandler",
"FTPHandler",
"CacheFTPHandler",
"DataHandler",
"UnknownHandler",
"HTTPErrorProcessor",
"urlopen",
"install_opener",
"build_opener",
"pathname2url",
"url2pathname",
"getproxies",
"urlretrieve",
"urlcleanup",
"URLopener",
"FancyURLopener",
"HTTPSHandler",
]

_T = TypeVar("_T")
_UrlopenRet = Any
_DataType = bytes | SupportsRead[bytes] | Iterable[bytes] | None
Expand Down
2 changes: 2 additions & 0 deletions stdlib/urllib/response.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ from email.message import Message
from types import TracebackType
from typing import IO, Any, BinaryIO, Callable, Iterable

__all__ = ["addbase", "addclosehook", "addinfo", "addinfourl"]

class addbase(BinaryIO):
fp: IO[bytes]
def __init__(self, fp: IO[bytes]) -> None: ...
Expand Down
6 changes: 4 additions & 2 deletions stdlib/urllib/robotparser.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import sys
from typing import Iterable, NamedTuple

class _RequestRate(NamedTuple):
__all__ = ["RobotFileParser"]

class RequestRate(NamedTuple):
requests: int
seconds: int

Expand All @@ -14,6 +16,6 @@ class RobotFileParser:
def mtime(self) -> int: ...
def modified(self) -> None: ...
def crawl_delay(self, useragent: str) -> str | None: ...
def request_rate(self, useragent: str) -> _RequestRate | None: ...
def request_rate(self, useragent: str) -> RequestRate | None: ...
if sys.version_info >= (3, 8):
def site_maps(self) -> list[str] | None: ...
2 changes: 2 additions & 0 deletions stdlib/uu.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import sys
from typing import BinaryIO, Union

__all__ = ["Error", "encode", "decode"]

_File = Union[str, BinaryIO]

class Error(Exception): ...
Expand Down
11 changes: 11 additions & 0 deletions stdlib/warnings.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ from types import ModuleType, TracebackType
from typing import Any, Sequence, TextIO, overload
from typing_extensions import Literal

__all__ = [
"warn",
"warn_explicit",
"showwarning",
"formatwarning",
"filterwarnings",
"simplefilter",
"resetwarnings",
"catch_warnings",
]

_ActionKind = Literal["default", "error", "ignore", "always", "module", "once"]

filters: Sequence[tuple[str, str | None, type[Warning], str | None, int]] # undocumented, do not mutate
Expand Down
5 changes: 5 additions & 0 deletions stdlib/wave.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ from _typeshed import ReadableBuffer, Self
from typing import IO, Any, BinaryIO, NamedTuple, NoReturn, Union, overload
from typing_extensions import Literal

if sys.version_info >= (3, 9):
__all__ = ["open", "Error", "Wave_read", "Wave_write"]
else:
__all__ = ["open", "openfp", "Error", "Wave_read", "Wave_write"]

_File = Union[str, IO[bytes]]

class Error(Exception): ...
Expand Down
16 changes: 16 additions & 0 deletions stdlib/weakref.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ from _weakref import (
ref as ref,
)

__all__ = [
"ref",
"proxy",
"getweakrefcount",
"getweakrefs",
"WeakKeyDictionary",
"ReferenceType",
"ProxyType",
"CallableProxyType",
"ProxyTypes",
"WeakValueDictionary",
"WeakSet",
"WeakMethod",
"finalize",
]

_T = TypeVar("_T")
_T1 = TypeVar("_T1")
_T2 = TypeVar("_T2")
Expand Down
2 changes: 2 additions & 0 deletions stdlib/webbrowser.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ from abc import abstractmethod
from typing import Callable, Sequence
from typing_extensions import Literal

__all__ = ["Error", "open", "open_new", "open_new_tab", "get", "register"]

class Error(Exception): ...

if sys.version_info >= (3, 7):
Expand Down
2 changes: 2 additions & 0 deletions stdlib/wsgiref/handlers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ from .headers import Headers
from .types import ErrorStream, InputStream, StartResponse, WSGIApplication, WSGIEnvironment
from .util import FileWrapper

__all__ = ["BaseHandler", "SimpleHandler", "BaseCGIHandler", "CGIHandler", "IISCGIHandler", "read_environ"]

_exc_info = tuple[Optional[type[BaseException]], Optional[BaseException], Optional[TracebackType]]

def format_date_time(timestamp: float | None) -> str: ... # undocumented
Expand Down
2 changes: 2 additions & 0 deletions stdlib/wsgiref/simple_server.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ from typing import TypeVar, overload
from .handlers import SimpleHandler
from .types import ErrorStream, StartResponse, WSGIApplication, WSGIEnvironment

__all__ = ["WSGIServer", "WSGIRequestHandler", "demo_app", "make_server"]

server_version: str # undocumented
sys_version: str # undocumented
software_version: str # undocumented
Expand Down
2 changes: 2 additions & 0 deletions stdlib/wsgiref/util.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ from typing import IO, Any, Callable

from .types import WSGIEnvironment

__all__ = ["FileWrapper", "guess_scheme", "application_uri", "request_uri", "shift_path_info", "setup_testing_defaults"]

class FileWrapper:
filelike: IO[bytes]
blksize: int
Expand Down
2 changes: 2 additions & 0 deletions stdlib/wsgiref/validate.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from _typeshed.wsgi import ErrorStream, InputStream, WSGIApplication
from typing import Any, Callable, Iterable, Iterator, NoReturn

__all__ = ["validator"]

class WSGIWarning(Warning): ...

def validator(application: WSGIApplication) -> WSGIApplication: ...
Expand Down
2 changes: 2 additions & 0 deletions stdlib/xdrlib.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import Callable, Sequence, TypeVar

__all__ = ["Error", "Packer", "Unpacker", "ConversionError"]

_T = TypeVar("_T")

class Error(Exception):
Expand Down
2 changes: 2 additions & 0 deletions stdlib/xml/dom/minicompat.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import Any, Iterable, TypeVar

__all__ = ["NodeList", "EmptyNodeList", "StringTypes", "defproperty"]

_T = TypeVar("_T")

StringTypes: tuple[type[str]]
Expand Down
2 changes: 2 additions & 0 deletions stdlib/xml/dom/xmlbuilder.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ from urllib.request import OpenerDirector
from xml.dom.expatbuilder import ExpatBuilder, ExpatBuilderNS
from xml.dom.minidom import Node

__all__ = ["DOMBuilder", "DOMEntityResolver", "DOMInputSource"]

# UNKNOWN TYPES:
# - `Options.errorHandler`.
# The same as `_DOMBuilderErrorHandlerType`?
Expand Down
84 changes: 84 additions & 0 deletions stdlib/xml/etree/ElementTree.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,90 @@ from typing import (
)
from typing_extensions import Literal, SupportsIndex, TypeGuard

if sys.version_info >= (3, 9):
__all__ = [
"Comment",
"dump",
"Element",
"ElementTree",
"fromstring",
"fromstringlist",
"indent",
"iselement",
"iterparse",
"parse",
"ParseError",
"PI",
"ProcessingInstruction",
"QName",
"SubElement",
"tostring",
"tostringlist",
"TreeBuilder",
"VERSION",
"XML",
"XMLID",
"XMLParser",
"XMLPullParser",
"register_namespace",
"canonicalize",
"C14NWriterTarget",
]
elif sys.version_info >= (3, 8):
__all__ = [
"Comment",
"dump",
"Element",
"ElementTree",
"fromstring",
"fromstringlist",
"iselement",
"iterparse",
"parse",
"ParseError",
"PI",
"ProcessingInstruction",
"QName",
"SubElement",
"tostring",
"tostringlist",
"TreeBuilder",
"VERSION",
"XML",
"XMLID",
"XMLParser",
"XMLPullParser",
"register_namespace",
"canonicalize",
"C14NWriterTarget",
]
else:
__all__ = [
"Comment",
"dump",
"Element",
"ElementTree",
"fromstring",
"fromstringlist",
"iselement",
"iterparse",
"parse",
"ParseError",
"PI",
"ProcessingInstruction",
"QName",
"SubElement",
"tostring",
"tostringlist",
"TreeBuilder",
"VERSION",
"XML",
"XMLID",
"XMLParser",
"XMLPullParser",
"register_namespace",
]

_T = TypeVar("_T")
_FileRead = Union[StrOrBytesPath, FileDescriptor, SupportsRead[bytes], SupportsRead[str]]
_FileWriteC14N = Union[StrOrBytesPath, FileDescriptor, SupportsWrite[bytes]]
Expand Down
2 changes: 2 additions & 0 deletions stdlib/zipapp.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import sys
from pathlib import Path
from typing import BinaryIO, Callable, Union

__all__ = ["ZipAppError", "create_archive", "get_interpreter"]

_Path = Union[str, Path, BinaryIO]

class ZipAppError(ValueError): ...
Expand Down
Loading