Skip to content

Commit 4ba81e8

Browse files
authored
Bump reportlab to 4.4.* (#13857)
1 parent ba0976e commit 4ba81e8

13 files changed

Lines changed: 200 additions & 127 deletions

File tree

stubs/reportlab/@tests/stubtest_allowlist.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ reportlab.graphics.shapes.Drawing.wrap
2020
reportlab\.platypus\.(doctemplate\.|flowables\.|tableofcontents\.)?[A-Za-z_]+\.split
2121
reportlab\.platypus\.(doctemplate\.|flowables\.|tableofcontents\.)?[A-Za-z_]+\.wrap
2222
reportlab.platypus.multicol.MultiCol.split
23-
reportlab.platypus.multicol.MultiCol.wrap
2423
reportlab.platypus.para.FastPara.split
2524
reportlab.platypus.para.FastPara.wrap
2625
reportlab.platypus.para.Para.split

stubs/reportlab/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "4.3.1"
1+
version = "4.4.*"
22
# GitHub mirror of https://hg.reportlab.com/hg-public/reportlab/file
33
upstream_repository = "https://github.com/MrBitBucket/reportlab-mirror"
44

stubs/reportlab/reportlab/graphics/renderPM.pyi

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,20 @@ class PMCanvas:
5050
def fillstrokepath(self, stroke: int = 1, fill: int = 1) -> None: ...
5151
def bezierArcCCW(self, cx, cy, rx, ry, theta0, theta1): ...
5252
def addEllipsoidalArc(self, cx, cy, rx, ry, ang1, ang2) -> None: ...
53-
def drawCentredString(self, x, y, text, text_anchor: str = "middle") -> None: ...
54-
def drawRightString(self, text, x, y) -> None: ...
55-
def drawString(self, x, y, text, _fontInfo: Incomplete | None = None, text_anchor: str = "left") -> None: ...
53+
def drawCentredString(
54+
self, x: float, y: float, text: str, text_anchor: str = "middle", direction: str | None = None, shaping: bool = False
55+
) -> None: ...
56+
def drawRightString(self, text: str, x: float, y: float, direction: str | None = None) -> None: ...
57+
def drawString(
58+
self,
59+
x: float,
60+
y: float,
61+
text: str,
62+
_fontInfo: Incomplete | None = None,
63+
text_anchor: str = "left",
64+
direction: str | None = None,
65+
shaping: bool = False,
66+
) -> None: ...
5667
def line(self, x1, y1, x2, y2) -> None: ...
5768
def rect(self, x, y, width, height, stroke: int = 1, fill: int = 1) -> None: ...
5869
def roundRect(self, x, y, width, height, rx, ry) -> None: ...
@@ -73,7 +84,6 @@ class PMCanvas:
7384
strokeWidth: Incomplete
7485
def setLineWidth(self, width) -> None: ...
7586
def stringWidth(self, text, fontName: Incomplete | None = None, fontSize: Incomplete | None = None): ...
76-
def shapedText(self, text) -> tuple[Incomplete, Incomplete]: ...
7787

7888
def drawToPMCanvas(
7989
d: Drawing,

stubs/reportlab/reportlab/lib/rl_accel.pyi

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
from typing import Literal
2+
13
def fp_str(*a): ...
24
def unicode2T1(utext, fonts): ...
3-
def instanceStringWidthT1(self, text, size, encoding: str = "utf8"): ...
4-
def instanceStringWidthTTF(self, text, size, encoding: str = "utf8"): ...
5-
def hex32(i): ...
6-
def add32(x, y): ...
7-
def calcChecksum(data): ...
5+
def instanceStringWidthT1(self, text: str, size: float, encoding: str = "utf8") -> float: ...
6+
def instanceStringWidthTTF(self, text: str, size: float, encoding: str = "utf8") -> float: ...
7+
def hex32(i) -> str: ...
8+
def add32(x: int, y: int) -> int: ...
9+
def calcChecksum(data: str | bytes) -> int: ...
810
def escapePDF(s): ...
9-
def asciiBase85Encode(input): ...
11+
def asciiBase85Encode(input: str) -> str: ...
1012
def asciiBase85Decode(input): ...
11-
def sameFrag(f, g): ...
13+
def sameFrag(f, g) -> bool | Literal[0]: ...
1214

1315
__all__ = [
1416
"fp_str",

stubs/reportlab/reportlab/lib/utils.pyi

Lines changed: 59 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import datetime
2+
import zipimport
23
from _typeshed import Incomplete, SupportsItems
3-
from collections.abc import Generator
4-
from typing import Final, Literal, TypeVar
4+
from collections.abc import Generator, Iterable
5+
from os import PathLike
6+
from types import TracebackType
7+
from typing import AnyStr, Final, Literal, TypeVar, overload
58

69
from reportlab.lib.rltempfile import get_rl_tempdir as get_rl_tempdir, get_rl_tempfile as get_rl_tempfile
710

@@ -24,37 +27,37 @@ __UNSET__: Final[_UNSET_]
2427

2528
isPyPy: bool
2629

27-
def isFunction(v): ...
28-
def isMethod(v, mt=...): ...
29-
def isModule(v): ...
30-
def isSeq(v, _st=...): ...
31-
def isNative(v): ...
32-
33-
strTypes: Incomplete
34-
35-
def asBytes(v, enc: str = "utf8"): ...
36-
def asUnicode(v, enc: str = "utf8"): ...
37-
def asUnicodeEx(v, enc: str = "utf8"): ...
38-
def asNative(v, enc: str = "utf8"): ...
39-
def int2Byte(i): ...
40-
def isStr(v): ...
41-
def isBytes(v): ...
42-
def isUnicode(v): ...
43-
def isClass(v): ...
44-
def isNonPrimitiveInstance(x): ...
45-
def instantiated(v): ...
46-
def bytestr(x, enc: str = "utf8"): ...
47-
def encode_label(args): ...
48-
def decode_label(label): ...
49-
def rawUnicode(s): ...
50-
def rawBytes(s): ...
51-
52-
rl_exec: Incomplete
53-
54-
def char2int(s): ...
55-
def rl_reraise(t, v, b: Incomplete | None = None) -> None: ...
30+
def isFunction(v: object) -> bool: ...
31+
def isMethod(v: object, mt=...) -> bool: ...
32+
def isModule(v: object) -> bool: ...
33+
def isSeq(v: object, _st=...) -> bool: ...
34+
def isNative(v: object) -> bool: ...
35+
36+
strTypes: tuple[type[str], type[bytes]]
37+
38+
def asBytes(v: str | bytes, enc: str = "utf8") -> bytes: ...
39+
def asUnicode(v: str | bytes, enc: str = "utf8") -> str: ...
40+
def asUnicodeEx(v: str | bytes, enc: str = "utf8") -> str: ...
41+
def asNative(v: str | bytes, enc: str = "utf8") -> str: ...
42+
def int2Byte(i: int) -> bytes: ...
43+
def isStr(v: object) -> bool: ...
44+
def isBytes(v: object) -> bool: ...
45+
def isUnicode(v: object) -> bool: ...
46+
def isClass(v: object) -> bool: ...
47+
def isNonPrimitiveInstance(x: object) -> bool: ...
48+
def instantiated(v: object) -> bool: ...
49+
def bytestr(x: object, enc: str = "utf8") -> bytes: ...
50+
def encode_label(args) -> str: ...
51+
def decode_label(label: str): ...
52+
def rawUnicode(s: str | bytes) -> str: ...
53+
def rawBytes(s: str | bytes) -> bytes: ...
54+
55+
rl_exec = exec
56+
57+
def char2int(s: int | str | bytes) -> int: ...
58+
def rl_reraise(t, v: BaseException, b: TracebackType | None = None) -> None: ...
5659
def rl_add_builtins(**kwd) -> None: ...
57-
def zipImported(ldr: Incomplete | None = None): ...
60+
def zipImported(ldr: zipimport.zipimporter | None = None) -> zipimport.zipimporter | None: ...
5861

5962
class CIDict(dict[_KT, _VT]):
6063
def __init__(self, *args, **kwds) -> None: ...
@@ -64,14 +67,14 @@ def markfilename(filename, creatorcode: Incomplete | None = None, filetype: Inco
6467

6568
__rl_loader__: Incomplete
6669

67-
def rl_glob(pattern, glob=...): ...
68-
def isFileSystemDistro(): ...
69-
def isCompactDistro(): ...
70-
def isSourceDistro(): ...
71-
def normalize_path(p): ...
70+
def rl_glob(pattern: AnyStr, glob=...) -> list[AnyStr]: ...
71+
def isFileSystemDistro() -> bool: ...
72+
def isCompactDistro() -> bool: ...
73+
def isSourceDistro() -> bool: ...
74+
def normalize_path(p: PathLike[AnyStr]) -> PathLike[AnyStr]: ...
7275
def recursiveImport(modulename, baseDir: Incomplete | None = None, noCWD: int = 0, debug: int = 0): ...
7376

74-
haveImages: Incomplete
77+
haveImages: Final[bool]
7578

7679
class ArgvDictValue:
7780
value: Incomplete
@@ -147,15 +150,18 @@ class _FmtSelfDict:
147150

148151
class FmtSelfDict: ...
149152

150-
def simpleSplit(text, fontName, fontSize, maxWidth): ...
151-
def escapeTextOnce(text): ...
153+
def simpleSplit(text: str | bytes, fontName: str | None, fontSize: float, maxWidth: float | None): ...
154+
@overload
155+
def escapeTextOnce(text: None) -> None: ...
156+
@overload
157+
def escapeTextOnce(text: str | bytes) -> str: ...
152158
def fileName2FSEnc(fn): ...
153159
def prev_this_next(items): ...
154-
def commasplit(s): ...
155-
def commajoin(l): ...
160+
def commasplit(s: str | bytes) -> list[str]: ...
161+
def commajoin(l: Iterable[str | bytes]) -> str: ...
156162
def findInPaths(fn, paths, isfile: bool = True, fail: bool = False): ...
157-
def annotateException(msg, enc: str = "utf8", postMsg: str = "", sep: str = " ") -> None: ...
158-
def escapeOnce(data): ...
163+
def annotateException(msg: str, enc: str = "utf8", postMsg: str = "", sep: str = " ") -> None: ...
164+
def escapeOnce(data: str) -> str: ...
159165

160166
class IdentStr(str):
161167
def __new__(cls, value): ...
@@ -188,3 +194,12 @@ def recursiveGetAttr(obj, name, g: Incomplete | None = None): ...
188194
def recursiveSetAttr(obj, name, value) -> None: ...
189195
def recursiveDelAttr(obj, name) -> None: ...
190196
def yieldNoneSplits(L) -> Generator[Incomplete, None, None]: ...
197+
198+
class KlassStore:
199+
lim: int
200+
store: dict[str, type]
201+
def __init__(self, lim: int = 127) -> None: ...
202+
def add(self, k: str, v: type) -> None: ...
203+
def __contains__(self, k) -> bool: ...
204+
def __getitem__(self, k: str) -> type: ...
205+
def get(self, k, default=None): ...

stubs/reportlab/reportlab/pdfbase/pdfmetrics.pyi

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from _typeshed import Incomplete
1+
from _typeshed import Incomplete, StrOrBytesPath
22
from typing import Final
33

44
from reportlab.lib.rl_accel import unicode2T1 as unicode2T1
@@ -10,7 +10,7 @@ standardEncodings: Incomplete
1010
class FontError(Exception): ...
1111
class FontNotFoundError(Exception): ...
1212

13-
def parseAFMFile(afmFileName): ...
13+
def parseAFMFile(afmFileName: StrOrBytesPath) -> tuple[dict[Incomplete, Incomplete], list[Incomplete]]: ...
1414

1515
class TypeFace:
1616
name: Incomplete
@@ -51,15 +51,15 @@ class Font:
5151
encoding: Incomplete
5252
encName: Incomplete
5353
substitutionFonts: Incomplete
54-
isShaped: bool
54+
shapable: bool
5555
def __init__(self, name, faceName, encName, substitutionFonts: Incomplete | None = None) -> None: ...
56-
def stringWidth(self, text, size, encoding: str = "utf8"): ...
56+
def stringWidth(self, text: str | bytes, size: float, encoding: str = "utf8") -> float: ...
5757
def addObjects(self, doc) -> None: ...
5858

59-
PFB_MARKER: Incomplete
60-
PFB_ASCII: Incomplete
61-
PFB_BINARY: Incomplete
62-
PFB_EOF: Incomplete
59+
PFB_MARKER: Final[str]
60+
PFB_ASCII: Final[str]
61+
PFB_BINARY: Final[str]
62+
PFB_EOF: Final[str]
6363

6464
class EmbeddedType1Face(TypeFace):
6565
afmFileName: Incomplete
@@ -81,13 +81,13 @@ def registerFontFamily(
8181
def registerFont(font) -> None: ...
8282
def getTypeFace(faceName): ...
8383
def getEncoding(encName): ...
84-
def findFontAndRegister(fontName): ...
85-
def getFont(fontName): ...
86-
def getAscentDescent(fontName, fontSize: Incomplete | None = None): ...
87-
def getAscent(fontName, fontSize: Incomplete | None = None): ...
88-
def getDescent(fontName, fontSize: Incomplete | None = None): ...
89-
def getRegisteredFontNames(): ...
90-
def stringWidth(text, fontName, fontSize, encoding: str = "utf8"): ...
84+
def findFontAndRegister(fontName: str) -> Font: ...
85+
def getFont(fontName: str) -> Font: ...
86+
def getAscentDescent(fontName: str, fontSize: float | None = None): ...
87+
def getAscent(fontName: str, fontSize: float | None = None): ...
88+
def getDescent(fontName: str, fontSize: float | None = None): ...
89+
def getRegisteredFontNames() -> list[Incomplete]: ...
90+
def stringWidth(text: str | bytes, fontName: str, fontSize: float, encoding: str = "utf8") -> float: ...
9191
def dumpFontData() -> None: ...
9292
def test3widths(texts) -> None: ...
9393
def testStringWidthAlgorithms() -> None: ...

stubs/reportlab/reportlab/pdfbase/ttfonts.pyi

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
1-
from _typeshed import Incomplete
1+
from _typeshed import Incomplete, ReadableBuffer, StrOrBytesPath
22
from typing import Final, NamedTuple
33
from typing_extensions import Self
4+
from weakref import WeakKeyDictionary
45

56
from reportlab.pdfbase import pdfdoc, pdfmetrics
67

78
__version__: Final[str]
89

910
class TTFError(pdfdoc.PDFError): ...
1011

11-
def SUBSETN(n, table=...): ...
12-
def makeToUnicodeCMap(fontname, subset): ...
12+
def SUBSETN(n, table: ReadableBuffer | None = ...) -> bytes: ...
13+
def makeToUnicodeCMap(fontname: str, subset) -> str: ...
1314
def splice(stream, offset, value): ...
1415

15-
GF_ARG_1_AND_2_ARE_WORDS: Incomplete
16-
GF_ARGS_ARE_XY_VALUES: Incomplete
17-
GF_ROUND_XY_TO_GRID: Incomplete
18-
GF_WE_HAVE_A_SCALE: Incomplete
19-
GF_RESERVED: Incomplete
20-
GF_MORE_COMPONENTS: Incomplete
21-
GF_WE_HAVE_AN_X_AND_Y_SCALE: Incomplete
22-
GF_WE_HAVE_A_TWO_BY_TWO: Incomplete
23-
GF_WE_HAVE_INSTRUCTIONS: Incomplete
24-
GF_USE_MY_METRICS: Incomplete
25-
GF_OVERLAP_COMPOUND: Incomplete
26-
GF_SCALED_COMPONENT_OFFSET: Incomplete
27-
GF_UNSCALED_COMPONENT_OFFSET: Incomplete
28-
29-
def TTFOpenFile(fn): ...
16+
GF_ARG_1_AND_2_ARE_WORDS: Final = 1
17+
GF_ARGS_ARE_XY_VALUES: Final = 2
18+
GF_ROUND_XY_TO_GRID: Final = 4
19+
GF_WE_HAVE_A_SCALE: Final = 8
20+
GF_RESERVED: Final = 16
21+
GF_MORE_COMPONENTS: Final = 32
22+
GF_WE_HAVE_AN_X_AND_Y_SCALE: Final = 64
23+
GF_WE_HAVE_A_TWO_BY_TWO: Final = 128
24+
GF_WE_HAVE_INSTRUCTIONS: Final = 256
25+
GF_USE_MY_METRICS: Final = 512
26+
GF_OVERLAP_COMPOUND: Final = 1024
27+
GF_SCALED_COMPONENT_OFFSET: Final = 2048
28+
GF_UNSCALED_COMPONENT_OFFSET: Final = 4096
29+
30+
def TTFOpenFile(fn: StrOrBytesPath) -> tuple[StrOrBytesPath,]: ...
3031

3132
class TTFontParser:
3233
ttfVersions: Incomplete
@@ -138,18 +139,18 @@ class TTFont:
138139
subsets: Incomplete
139140
def __init__(self, asciiReadable: Incomplete | None = None, ttf: Incomplete | None = None) -> None: ...
140141

141-
fontName: Incomplete
142-
face: Incomplete
143-
encoding: Incomplete
144-
state: Incomplete
142+
fontName: str
143+
face: TTFontFace
144+
encoding: TTEncoding
145+
state: WeakKeyDictionary[Incomplete, State]
145146
def __init__(
146147
self,
147-
name,
148+
name: str,
148149
filename,
149150
validate: int = 0,
150151
subfontIndex: int = 0,
151-
asciiReadable: Incomplete | None = None,
152-
shaped: Incomplete | None = None,
152+
asciiReadable: int | None = None,
153+
shapable: bool = True,
153154
) -> None: ...
154155
def stringWidth(self, text, size, encoding: str = "utf8"): ...
155156
def splitString(self, text, doc, encoding: str = "utf-8"): ...
@@ -159,9 +160,9 @@ class TTFont:
159160
def hbFace(self) -> Incomplete | None: ...
160161
def hbFont(self, fontSize: float = 10): ...
161162
@property
162-
def isShaped(self) -> bool: ...
163-
@isShaped.setter
164-
def isShaped(self, v) -> None: ...
163+
def shapable(self) -> bool: ...
164+
@shapable.setter
165+
def shapable(self, v) -> None: ...
165166
def pdfScale(self, v): ...
166167
def unregister(self) -> None: ...
167168

@@ -179,6 +180,7 @@ class ShapedStr(str):
179180
def __new__(cls, s, shapeData: ShapeData | None = None) -> Self: ...
180181
def __radd__(self, other) -> Self: ...
181182

183+
def shapeStr(s: str, fontName: str, fontSize: float): ...
182184
def freshTTFont(ttfn, ttfpath, **kwds) -> TTFont: ...
183185
def makeShapedFragWord(w, K: list[Incomplete] = [], V: list[Incomplete] = []) -> type[ShapedFragWord]: ...
184186
def shapeFragWord(w, features: Incomplete | None = None): ...

0 commit comments

Comments
 (0)