Skip to content

Commit f2dbab1

Browse files
committed
Merge branch 'main' of https://github.com/python/typeshed into removing-setuptools._distutils
2 parents 690cf3c + f65bdc1 commit f2dbab1

File tree

6 files changed

+63
-38
lines changed

6 files changed

+63
-38
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from __future__ import annotations
2+
3+
from urllib.parse import quote, quote_plus, urlencode
4+
5+
urlencode({"a": "b"}, quote_via=quote)
6+
urlencode({b"a": b"b"}, quote_via=quote)
7+
urlencode({"a": b"b"}, quote_via=quote)
8+
urlencode({b"a": "b"}, quote_via=quote)
9+
mixed_dict: dict[str | bytes, str | bytes] = {}
10+
urlencode(mixed_dict, quote_via=quote)
11+
12+
urlencode({"a": "b"}, quote_via=quote_plus)

stdlib/ssl.pyi

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ from _ssl import (
2828
from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer
2929
from collections.abc import Callable, Iterable
3030
from typing import Any, Literal, NamedTuple, TypedDict, overload, type_check_only
31-
from typing_extensions import Never, Self, TypeAlias
31+
from typing_extensions import Never, Self, TypeAlias, deprecated
3232

3333
if sys.version_info >= (3, 13):
3434
from _ssl import HAS_PSK as HAS_PSK
@@ -369,7 +369,12 @@ class SSLSocket(socket.socket):
369369
def compression(self) -> str | None: ...
370370
def get_channel_binding(self, cb_type: str = "tls-unique") -> bytes | None: ...
371371
def selected_alpn_protocol(self) -> str | None: ...
372-
def selected_npn_protocol(self) -> str | None: ...
372+
if sys.version_info >= (3, 10):
373+
@deprecated("Deprecated in 3.10. Use ALPN instead.")
374+
def selected_npn_protocol(self) -> str | None: ...
375+
else:
376+
def selected_npn_protocol(self) -> str | None: ...
377+
373378
def accept(self) -> tuple[SSLSocket, socket._RetAddress]: ...
374379
def unwrap(self) -> socket.socket: ...
375380
def version(self) -> str | None: ...
@@ -434,7 +439,12 @@ class SSLContext(_SSLContext):
434439
def set_default_verify_paths(self) -> None: ...
435440
def set_ciphers(self, cipherlist: str, /) -> None: ...
436441
def set_alpn_protocols(self, alpn_protocols: Iterable[str]) -> None: ...
437-
def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ...
442+
if sys.version_info >= (3, 10):
443+
@deprecated("Deprecated in 3.10. Use ALPN instead.")
444+
def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ...
445+
else:
446+
def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ...
447+
438448
def set_servername_callback(self, server_name_callback: _SrvnmeCbType | None) -> None: ...
439449
def load_dh_params(self, path: str, /) -> None: ...
440450
def set_ecdh_curve(self, name: str, /) -> None: ...
@@ -475,7 +485,12 @@ class SSLObject:
475485
@overload
476486
def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ...
477487
def selected_alpn_protocol(self) -> str | None: ...
478-
def selected_npn_protocol(self) -> str | None: ...
488+
if sys.version_info >= (3, 10):
489+
@deprecated("Deprecated in 3.10. Use ALPN instead.")
490+
def selected_npn_protocol(self) -> str | None: ...
491+
else:
492+
def selected_npn_protocol(self) -> str | None: ...
493+
479494
def cipher(self) -> tuple[str, str, int] | None: ...
480495
def shared_ciphers(self) -> list[tuple[str, str, int]] | None: ...
481496
def compression(self) -> str | None: ...

stdlib/urllib/parse.pyi

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
2-
from collections.abc import Callable, Iterable, Mapping, Sequence
2+
from collections.abc import Iterable, Mapping, Sequence
33
from types import GenericAlias
4-
from typing import Any, AnyStr, Generic, Literal, NamedTuple, TypeVar, overload
4+
from typing import Any, AnyStr, Generic, Literal, NamedTuple, Protocol, overload, type_check_only
55
from typing_extensions import TypeAlias
66

77
__all__ = [
@@ -132,38 +132,32 @@ def urldefrag(url: str) -> DefragResult: ...
132132
@overload
133133
def urldefrag(url: bytes | bytearray | None) -> DefragResultBytes: ...
134134

135-
_Q = TypeVar("_Q", bound=str | Iterable[int])
135+
# The values are passed through `str()` (unless they are bytes), so anything is valid.
136136
_QueryType: TypeAlias = (
137-
Mapping[Any, Any] | Mapping[Any, Sequence[Any]] | Sequence[tuple[Any, Any]] | Sequence[tuple[Any, Sequence[Any]]]
137+
Mapping[str, object]
138+
| Mapping[bytes, object]
139+
| Mapping[str | bytes, object]
140+
| Mapping[str, Sequence[object]]
141+
| Mapping[bytes, Sequence[object]]
142+
| Mapping[str | bytes, Sequence[object]]
143+
| Sequence[tuple[str | bytes, object]]
144+
| Sequence[tuple[str | bytes, Sequence[object]]]
138145
)
139146

140-
@overload
141-
def urlencode(
142-
query: _QueryType,
143-
doseq: bool = False,
144-
safe: str = "",
145-
encoding: str | None = None,
146-
errors: str | None = None,
147-
quote_via: Callable[[AnyStr, str, str, str], str] = ...,
148-
) -> str: ...
149-
@overload
150-
def urlencode(
151-
query: _QueryType,
152-
doseq: bool,
153-
safe: _Q,
154-
encoding: str | None = None,
155-
errors: str | None = None,
156-
quote_via: Callable[[AnyStr, _Q, str, str], str] = ...,
157-
) -> str: ...
158-
@overload
147+
@type_check_only
148+
class _QuoteVia(Protocol):
149+
@overload
150+
def __call__(self, string: str, safe: str | bytes, encoding: str, errors: str, /) -> str: ...
151+
@overload
152+
def __call__(self, string: bytes, safe: str | bytes, /) -> str: ...
153+
159154
def urlencode(
160155
query: _QueryType,
161156
doseq: bool = False,
162-
*,
163-
safe: _Q,
157+
safe: str | bytes = "",
164158
encoding: str | None = None,
165159
errors: str | None = None,
166-
quote_via: Callable[[AnyStr, _Q, str, str], str] = ...,
160+
quote_via: _QuoteVia = ...,
167161
) -> str: ...
168162
def urljoin(base: AnyStr, url: AnyStr | None, allow_fragments: bool = True) -> AnyStr: ...
169163
@overload

stubs/Markdown/markdown/util.pyi

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from collections.abc import Iterator
23
from re import Pattern
34
from typing import Final, Generic, TypedDict, TypeVar, overload
@@ -18,7 +19,13 @@ HTML_PLACEHOLDER_RE: Final[Pattern[str]]
1819
TAG_PLACEHOLDER: Final[str]
1920
RTL_BIDI_RANGES: Final[tuple[tuple[str, str], tuple[str, str]]]
2021

21-
def get_installed_extensions(): ...
22+
if sys.version_info >= (3, 10):
23+
from importlib import metadata
24+
def get_installed_extensions() -> metadata.EntryPoints: ...
25+
26+
else:
27+
def get_installed_extensions(): ...
28+
2229
def deprecated(message: str, stacklevel: int = 2): ...
2330
@overload
2431
def parseBoolValue(value: str) -> bool: ...
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
version = "2.5.*"
22
upstream_repository = "https://github.com/gforcada/flake8-builtins"
3-
partial_stub = true
4-
5-
[tool.stubtest]
6-
ignore_missing_stub = true
3+
requires = ["types-flake8"]

stubs/flake8-builtins/flake8_builtins.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import ast
22
from argparse import Namespace
3-
from binascii import Incomplete
43
from collections.abc import Iterator
54
from typing import ClassVar
65
from typing_extensions import TypeAlias
76

7+
from flake8.options.manager import OptionManager
8+
89
_Error: TypeAlias = tuple[int, int, str, type[BuiltinsChecker]]
9-
_OptionManager: TypeAlias = Incomplete # flake8.options.manager.OptionManager
1010

1111
class BuiltinsChecker:
1212
name: ClassVar[str]
@@ -24,7 +24,7 @@ class BuiltinsChecker:
2424

2525
def __init__(self, tree: ast.AST, filename: str) -> None: ...
2626
@classmethod
27-
def add_options(cls, option_manager: _OptionManager) -> None: ...
27+
def add_options(cls, option_manager: OptionManager) -> None: ...
2828
@classmethod
2929
def parse_options(cls, options: Namespace) -> None: ...
3030
def run(self) -> Iterator[_Error]: ...

0 commit comments

Comments
 (0)