Skip to content

Commit 27daf62

Browse files
authored
Merge branch 'main' into fpdf2-2.8.5
2 parents 4097308 + bbbf753 commit 27daf62

File tree

160 files changed

+2628
-1447
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+2628
-1447
lines changed

pyrightconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
// No effect in stubs
2929
"reportMissingSuperCall": "none",
3030
"reportUninitializedInstanceVariable": "none",
31-
// stdlib stubs trigger reportShadowedImports
32-
"reportShadowedImports": "none",
3331
// Stubs are allowed to use private variables
3432
"reportPrivateUsage": "none",
3533
// Stubs don't need the actual modules to be installed

pyrightconfig.scripts_and_tests.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"reportImplicitStringConcatenation": "none",
1515
// Extra strict settings
1616
"reportMissingModuleSource": "error",
17-
"reportShadowedImports": "error",
1817
"reportCallInDefaultInitializer": "error",
1918
"reportPropertyTypeMismatch": "error",
2019
"reportUninitializedInstanceVariable": "error",

pyrightconfig.stricter.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"stubs/boltons",
3131
"stubs/braintree",
3232
"stubs/cffi",
33+
"stubs/colorful",
3334
"stubs/dateparser",
3435
"stubs/defusedxml",
3536
"stubs/docker",
@@ -79,7 +80,6 @@
7980
"stubs/PyMySQL",
8081
"stubs/python-dateutil",
8182
"stubs/python-jose",
82-
"stubs/pytz/pytz/lazy.pyi",
8383
"stubs/pywin32",
8484
"stubs/PyYAML",
8585
"stubs/reportlab",
@@ -108,8 +108,6 @@
108108
// No effect in stubs
109109
"reportMissingSuperCall": "none",
110110
"reportUninitializedInstanceVariable": "none",
111-
// stdlib stubs trigger reportShadowedImports
112-
"reportShadowedImports": "none",
113111
// Stubs are allowed to use private variables
114112
"reportPrivateUsage": "none",
115113
// Stubs don't need the actual modules to be installed

pyrightconfig.testcases.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
],
77
"typeCheckingMode": "strict",
88
// Extra strict settings
9-
"reportShadowedImports": "error", // Don't accidentally name a file something that shadows stdlib
109
"reportImplicitStringConcatenation": "error",
1110
"reportUninitializedInstanceVariable": "error",
1211
"reportUnnecessaryTypeIgnoreComment": "error",

stdlib/@tests/stubtest_allowlists/darwin.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ multiprocessing.popen_spawn_win32 # exists on Darwin but fails to import
5353
readline.append_history_file # Only available if compiled with GNU readline, not editline
5454
select.poll # Actually a function; we have a class so it can be used as a type
5555

56-
# Some of these exist on non-windows, but they are useless and this is not intended
57-
stat.FILE_ATTRIBUTE_[A-Z_]+
58-
5956
tkinter.Tk.createfilehandler # Methods that come from __getattr__() at runtime
6057
tkinter.Tk.deletefilehandler # Methods that come from __getattr__() at runtime
6158

stdlib/@tests/stubtest_allowlists/linux.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ _?socket.SOL_IPX
5454
_?socket.SOL_NETROM
5555
_?socket.SOL_ROSE
5656

57-
# Some of these exist on non-windows, but they are useless and this is not intended
58-
stat.FILE_ATTRIBUTE_[A-Z_]+
59-
6057
# This is available on Linux, but it's documented as for kernel debugging and
6158
# not present on GitHub Actions runners.
6259
termios.TIOCTTYGSTRUCT
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
from __future__ import annotations
2+
3+
import io
4+
import sys
5+
from _typeshed import ReadableBuffer
6+
from bz2 import BZ2Decompressor
7+
from lzma import LZMADecompressor
8+
from typing import cast
9+
from typing_extensions import assert_type
10+
from zlib import decompressobj
11+
12+
if sys.version_info >= (3, 14):
13+
from compression._common._streams import DecompressReader, _Decompressor, _Reader
14+
from compression.zstd import ZstdDecompressor
15+
else:
16+
from _compression import DecompressReader, _Decompressor, _Reader
17+
18+
###
19+
# Tests for DecompressReader/_Decompressor
20+
###
21+
22+
23+
class CustomDecompressor:
24+
def decompress(self, data: ReadableBuffer, max_length: int = -1) -> bytes:
25+
return b""
26+
27+
@property
28+
def unused_data(self) -> bytes:
29+
return b""
30+
31+
@property
32+
def eof(self) -> bool:
33+
return False
34+
35+
@property
36+
def needs_input(self) -> bool:
37+
return False
38+
39+
40+
def accept_decompressor(d: _Decompressor) -> None:
41+
d.decompress(b"random bytes", 0)
42+
assert_type(d.eof, bool)
43+
assert_type(d.unused_data, bytes)
44+
45+
46+
fp = cast(_Reader, io.BytesIO(b"hello world"))
47+
DecompressReader(fp, decompressobj)
48+
DecompressReader(fp, BZ2Decompressor)
49+
DecompressReader(fp, LZMADecompressor)
50+
DecompressReader(fp, CustomDecompressor)
51+
accept_decompressor(decompressobj())
52+
accept_decompressor(BZ2Decompressor())
53+
accept_decompressor(LZMADecompressor())
54+
accept_decompressor(CustomDecompressor())
55+
56+
if sys.version_info >= (3, 14):
57+
DecompressReader(fp, ZstdDecompressor)
58+
accept_decompressor(ZstdDecompressor())

stdlib/_compression.pyi

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# _compression is replaced by compression._common._streams on Python 3.14+ (PEP-784)
22

3-
from _typeshed import Incomplete, WriteableBuffer
3+
from _typeshed import ReadableBuffer, WriteableBuffer
44
from collections.abc import Callable
55
from io import DEFAULT_BUFFER_SIZE, BufferedIOBase, RawIOBase
66
from typing import Any, Protocol, type_check_only
@@ -13,13 +13,24 @@ class _Reader(Protocol):
1313
def seekable(self) -> bool: ...
1414
def seek(self, n: int, /) -> Any: ...
1515

16+
@type_check_only
17+
class _Decompressor(Protocol):
18+
def decompress(self, data: ReadableBuffer, /, max_length: int = ...) -> bytes: ...
19+
@property
20+
def unused_data(self) -> bytes: ...
21+
@property
22+
def eof(self) -> bool: ...
23+
# `zlib._Decompress` does not have next property, but `DecompressReader` calls it:
24+
# @property
25+
# def needs_input(self) -> bool: ...
26+
1627
class BaseStream(BufferedIOBase): ...
1728

1829
class DecompressReader(RawIOBase):
1930
def __init__(
2031
self,
2132
fp: _Reader,
22-
decomp_factory: Callable[..., Incomplete],
33+
decomp_factory: Callable[..., _Decompressor],
2334
trailing_error: type[Exception] | tuple[type[Exception], ...] = (),
2435
**decomp_args: Any, # These are passed to decomp_factory.
2536
) -> None: ...

stdlib/compression/_common/_streams.pyi

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from _typeshed import Incomplete, WriteableBuffer
1+
from _typeshed import ReadableBuffer, WriteableBuffer
22
from collections.abc import Callable
33
from io import DEFAULT_BUFFER_SIZE, BufferedIOBase, RawIOBase
44
from typing import Any, Protocol, type_check_only
@@ -11,13 +11,24 @@ class _Reader(Protocol):
1111
def seekable(self) -> bool: ...
1212
def seek(self, n: int, /) -> Any: ...
1313

14+
@type_check_only
15+
class _Decompressor(Protocol):
16+
def decompress(self, data: ReadableBuffer, /, max_length: int = ...) -> bytes: ...
17+
@property
18+
def unused_data(self) -> bytes: ...
19+
@property
20+
def eof(self) -> bool: ...
21+
# `zlib._Decompress` does not have next property, but `DecompressReader` calls it:
22+
# @property
23+
# def needs_input(self) -> bool: ...
24+
1425
class BaseStream(BufferedIOBase): ...
1526

1627
class DecompressReader(RawIOBase):
1728
def __init__(
1829
self,
1930
fp: _Reader,
20-
decomp_factory: Callable[..., Incomplete], # Consider backporting changes to _compression
31+
decomp_factory: Callable[..., _Decompressor], # Consider backporting changes to _compression
2132
trailing_error: type[Exception] | tuple[type[Exception], ...] = (),
2233
**decomp_args: Any, # These are passed to decomp_factory.
2334
) -> None: ...

stdlib/http/client.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ class HTTPResponse(io.BufferedIOBase, BinaryIO): # type: ignore[misc] # incomp
166166
def begin(self) -> None: ...
167167

168168
class HTTPConnection:
169+
blocksize: int
169170
auto_open: int # undocumented
170171
debuglevel: int
171172
default_port: int # undocumented

0 commit comments

Comments
 (0)