Skip to content

Commit 789bc53

Browse files
authored
[reportlab] Add more annotations for pdfbase (#15431)
1 parent 5af6060 commit 789bc53

File tree

11 files changed

+531
-374
lines changed

11 files changed

+531
-374
lines changed

stubs/reportlab/reportlab/lib/rl_accel.pyi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
from _typeshed import Incomplete
12
from typing import Literal
23

3-
def fp_str(*a): ...
4-
def unicode2T1(utext, fonts): ...
4+
def fp_str(*a) -> str: ...
5+
def unicode2T1(utext, fonts) -> list[tuple[Incomplete, Incomplete]]: ...
56
def instanceStringWidthT1(self, text: str, size: float, encoding: str = "utf8") -> float: ...
67
def instanceStringWidthTTF(self, text: str, size: float, encoding: str = "utf8") -> float: ...
78
def hex32(i) -> str: ...
89
def add32(x: int, y: int) -> int: ...
910
def calcChecksum(data: str | bytes) -> int: ...
10-
def escapePDF(s): ...
11+
def escapePDF(s) -> str: ...
1112
def asciiBase85Encode(input: str) -> str: ...
12-
def asciiBase85Decode(input): ...
13+
def asciiBase85Decode(input) -> bytes: ...
1314
def sameFrag(f, g) -> bool | Literal[0]: ...
1415

1516
__all__ = [

stubs/reportlab/reportlab/lib/utils.pyi

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import zipimport
33
from _typeshed import Incomplete, SupportsItems
44
from collections.abc import Generator, Iterable, MutableMapping
55
from os import PathLike
6+
from time import _TimeTuple, struct_time
67
from types import TracebackType
78
from typing import AnyStr, Final, Literal, TypeVar, overload, type_check_only
89
from urllib.request import _UrlopenRet
@@ -174,23 +175,23 @@ class RLString(str):
174175
def makeFileName(s): ...
175176

176177
class FixedOffsetTZ(datetime.tzinfo):
177-
def __init__(self, h, m, name) -> None: ...
178-
def utcoffset(self, dt): ...
179-
def tzname(self, dt): ...
180-
def dst(self, dt): ...
178+
def __init__(self, h: float, m: float, name: str | None) -> None: ...
179+
def utcoffset(self, dt: datetime.datetime | None) -> datetime.timedelta: ...
180+
def tzname(self, dt: datetime.datetime | None) -> str | None: ...
181+
def dst(self, dt: datetime.datetime | None) -> datetime.timedelta: ...
181182

182183
class TimeStamp:
183184
tzname: str
184-
t: Incomplete
185-
lt: Incomplete
186-
YMDhms: Incomplete
187-
dhh: Incomplete
188-
dmm: Incomplete
189-
def __init__(self, invariant=None) -> None: ...
185+
t: float
186+
lt: struct_time | _TimeTuple
187+
YMDhms: tuple[int, ...]
188+
dhh: int
189+
dmm: int
190+
def __init__(self, invariant: int | bool | None = None) -> None: ...
190191
@property
191-
def datetime(self): ...
192+
def datetime(self) -> datetime.datetime: ...
192193
@property
193-
def asctime(self): ...
194+
def asctime(self) -> str: ...
194195

195196
def recursiveGetAttr(obj, name, g=None): ...
196197
def recursiveSetAttr(obj, name, value) -> None: ...

stubs/reportlab/reportlab/pdfbase/acroform.pyi

Lines changed: 161 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,47 @@
11
from _typeshed import Incomplete
2+
from weakref import ReferenceType
23

3-
from reportlab.pdfbase.pdfdoc import PDFObject
4+
from reportlab.pdfbase.pdfdoc import PDFDictionary, PDFObject, PDFStream
45

56
__all__ = ("AcroForm",)
67

8+
visibilities: dict[str, int]
9+
orientations: dict[str, list[Incomplete]]
10+
fieldFlagValues: dict[str, int]
11+
annotationFlagValues: dict[str, int]
12+
13+
def bsPDF(borderWidth: int, borderStyle: str, dashLen) -> PDFDictionary: ...
14+
def escPDF(s) -> str: ...
15+
def makeFlags(s: int | str, d: dict[str, int] = ...) -> int: ...
16+
717
class PDFFromString(PDFObject):
8-
def __init__(self, s) -> None: ...
9-
def format(self, document): ...
18+
def __init__(self, s: str | bytes) -> None: ...
19+
def format(self, document) -> bytes: ...
1020

1121
class RadioGroup(PDFObject):
1222
TU: Incomplete
13-
Ff: Incomplete
14-
kids: Incomplete
23+
Ff: int
24+
kids: list[Incomplete]
1525
T: Incomplete
1626
V: Incomplete
1727
def __init__(self, name, tooltip: str = "", fieldFlags: str = "noToggleToOff required radio") -> None: ...
18-
def format(self, doc): ...
28+
def format(self, doc) -> bytes: ...
1929

2030
class AcroForm(PDFObject):
21-
formFontNames: Incomplete
22-
referenceMap: Incomplete
23-
fonts: Incomplete
24-
fields: Incomplete
31+
formFontNames: dict[str, str]
32+
referenceMap: dict[Incomplete, Incomplete]
33+
fonts: dict[str, str]
34+
fields: list[Incomplete]
2535
sigFlags: Incomplete
26-
extras: Incomplete
36+
extras: dict[Incomplete, Incomplete]
2737
def __init__(self, canv, **kwds) -> None: ...
2838
@property
29-
def canv(self): ...
30-
def fontRef(self, f): ...
31-
def format(self, doc): ...
39+
def canv(self) -> ReferenceType[Incomplete]: ...
40+
def fontRef(self, f) -> str: ...
41+
def format(self, doc) -> bytes: ...
3242
def colorTuple(self, c): ...
33-
def streamFillColor(self, c): ...
34-
def streamStrokeColor(self, c): ...
43+
def streamFillColor(self, c) -> str: ...
44+
def streamStrokeColor(self, c) -> str: ...
3545
def checkboxAP(
3646
self,
3747
key,
@@ -45,16 +55,16 @@ class AcroForm(PDFObject):
4555
borderStyle: str = "solid",
4656
size: int = 20,
4757
dashLen: int = 3,
48-
): ...
58+
) -> PDFStream: ...
4959
@staticmethod
50-
def circleArcStream(size, r, arcs=(0, 1, 2, 3), rotated: bool = False): ...
51-
def zdMark(self, c, size, ds, iFontName): ...
60+
def circleArcStream(size, r, arcs=(0, 1, 2, 3), rotated: bool = False) -> str: ...
61+
def zdMark(self, c, size, ds, iFontName) -> str: ...
5262
def getRef(self, obj): ...
53-
def getRefStr(self, obj): ...
63+
def getRefStr(self, obj) -> str: ...
5464
@staticmethod
55-
def stdColors(t, b, f): ...
65+
def stdColors(t, b, f) -> tuple[Incomplete, Incomplete, Incomplete]: ...
5666
@staticmethod
57-
def varyColors(key, t, b, f): ...
67+
def varyColors(key, t, b, f) -> tuple[Incomplete, Incomplete, Incomplete]: ...
5868
def checkForceBorder(
5969
self, x, y, width, height, forceBorder, shape, borderStyle, borderWidth, borderColor, fillColor
6070
) -> None: ...
@@ -101,7 +111,7 @@ class AcroForm(PDFObject):
101111
relative: bool = False,
102112
dashLen: int = 3,
103113
) -> None: ...
104-
def makeStream(self, width, height, stream, **D): ...
114+
def makeStream(self, width, height, stream, **D) -> PDFStream: ...
105115
def txAP(
106116
self,
107117
key,
@@ -123,8 +133,8 @@ class AcroForm(PDFObject):
123133
I=[],
124134
sel_bg: str = "0.600006 0.756866 0.854904 rg",
125135
sel_fg: str = "0 g",
126-
): ...
127-
def makeFont(self, fontName): ...
136+
) -> PDFStream: ...
137+
def makeFont(self, fontName: str | None) -> tuple[str, str]: ...
128138
def textfield(
129139
self,
130140
value: str = "",
@@ -144,10 +154,10 @@ class AcroForm(PDFObject):
144154
forceBorder: bool = False,
145155
relative: bool = False,
146156
maxlen: int = 100,
147-
fontName=None,
157+
fontName: str | None = None,
148158
fontSize=None,
149159
dashLen: int = 3,
150-
): ...
160+
) -> None: ...
151161
def listbox(
152162
self,
153163
value: str = "",
@@ -166,12 +176,12 @@ class AcroForm(PDFObject):
166176
fieldFlags: str = "",
167177
forceBorder: bool = False,
168178
relative: bool = False,
169-
fontName=None,
179+
fontName: str | None = None,
170180
fontSize=None,
171181
dashLen: int = 3,
172182
maxlen=None,
173183
options=[],
174-
): ...
184+
) -> None: ...
175185
def choice(
176186
self,
177187
value: str = "",
@@ -190,25 +200,136 @@ class AcroForm(PDFObject):
190200
fieldFlags: str = "combo",
191201
forceBorder: bool = False,
192202
relative: bool = False,
193-
fontName=None,
203+
fontName: str | None = None,
194204
fontSize=None,
195205
dashLen: int = 3,
196206
maxlen=None,
197207
options=[],
198-
): ...
199-
def checkboxRelative(self, **kwds) -> None: ...
200-
def radioRelative(self, **kwds) -> None: ...
201-
def textfieldRelative(self, **kwds) -> None: ...
202-
def listboxRelative(self, **kwds) -> None: ...
203-
def choiceRelative(self, **kwds) -> None: ...
208+
) -> None: ...
209+
def checkboxRelative(
210+
self,
211+
*,
212+
checked: bool = False,
213+
buttonStyle: str = "check",
214+
shape: str = "square",
215+
fillColor=None,
216+
borderColor=None,
217+
textColor=None,
218+
borderWidth: int = 1,
219+
borderStyle: str = "solid",
220+
size: int = 20,
221+
x: int = 0,
222+
y: int = 0,
223+
tooltip=None,
224+
name=None,
225+
annotationFlags: str = "print",
226+
fieldFlags: str = "required",
227+
forceBorder: bool = False,
228+
dashLen: int = 3,
229+
) -> None: ...
230+
def radioRelative(
231+
self,
232+
*,
233+
value=None,
234+
selected: bool = False,
235+
buttonStyle: str = "circle",
236+
shape: str = "circle",
237+
fillColor=None,
238+
borderColor=None,
239+
textColor=None,
240+
borderWidth: int = 1,
241+
borderStyle: str = "solid",
242+
size: int = 20,
243+
x: int = 0,
244+
y: int = 0,
245+
tooltip=None,
246+
name=None,
247+
annotationFlags: str = "print",
248+
fieldFlags: str = "noToggleToOff required radio",
249+
forceBorder: bool = False,
250+
dashLen: int = 3,
251+
) -> None: ...
252+
def textfieldRelative(
253+
self,
254+
*,
255+
value: str = "",
256+
fillColor=None,
257+
borderColor=None,
258+
textColor=None,
259+
borderWidth: int = 1,
260+
borderStyle: str = "solid",
261+
width: int = 120,
262+
height: int = 36,
263+
x: int = 0,
264+
y: int = 0,
265+
tooltip=None,
266+
name=None,
267+
annotationFlags: str = "print",
268+
fieldFlags: str = "",
269+
forceBorder: bool = False,
270+
maxlen: int = 100,
271+
fontName: str | None = None,
272+
fontSize=None,
273+
dashLen: int = 3,
274+
) -> None: ...
275+
def listboxRelative(
276+
self,
277+
*,
278+
value: str = "",
279+
fillColor=None,
280+
borderColor=None,
281+
textColor=None,
282+
borderWidth: int = 1,
283+
borderStyle: str = "solid",
284+
width: int = 120,
285+
height: int = 36,
286+
x: int = 0,
287+
y: int = 0,
288+
tooltip=None,
289+
name=None,
290+
annotationFlags: str = "print",
291+
fieldFlags: str = "",
292+
forceBorder: bool = False,
293+
maxlen: int = 100,
294+
fontName: str | None = None,
295+
fontSize=None,
296+
dashLen: int = 3,
297+
) -> None: ...
298+
def choiceRelative(
299+
self,
300+
*,
301+
value: str = "",
302+
fillColor=None,
303+
borderColor=None,
304+
textColor=None,
305+
borderWidth: int = 1,
306+
borderStyle: str = "solid",
307+
width: int = 120,
308+
height: int = 36,
309+
x: int = 0,
310+
y: int = 0,
311+
tooltip=None,
312+
name=None,
313+
annotationFlags: str = "print",
314+
fieldFlags: str = "",
315+
forceBorder: bool = False,
316+
maxlen: int = 100,
317+
fontName: str | None = None,
318+
fontSize=None,
319+
dashLen: int = 3,
320+
) -> None: ...
204321
@property
205-
def encRefStr(self): ...
322+
def encRefStr(self) -> str: ...
206323

207324
class CBMark:
208-
opNames: Incomplete
209-
opCount: Incomplete
325+
opNames: list[str]
326+
opCount: tuple[int, ...]
210327
ops: Incomplete
328+
xmin: Incomplete
329+
ymin: Incomplete
330+
xmax: Incomplete
331+
ymax: Incomplete
211332
points: Incomplete
212333
slack: Incomplete
213334
def __init__(self, ops, points, bounds, slack: float = 0.05) -> None: ...
214-
def scaledRender(self, size, ds: int = 0): ...
335+
def scaledRender(self, size, ds: int = 0) -> str: ...

0 commit comments

Comments
 (0)