Skip to content

Commit 8f4e68e

Browse files
committed
[reportlab] Add more annotations for pdfbase
1 parent aab5cc6 commit 8f4e68e

File tree

11 files changed

+537
-375
lines changed

11 files changed

+537
-375
lines changed

stubs/reportlab/reportlab/lib/rl_accel.pyi

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
from _typeshed import Incomplete
12
from typing import Literal
3+
from typing_extensions import LiteralString
24

3-
def fp_str(*a): ...
4-
def unicode2T1(utext, fonts): ...
5+
def fp_str(*a) -> LiteralString: ...
6+
def unicode2T1(utext, fonts) -> list[tuple[Incomplete, Incomplete]]: ...
57
def instanceStringWidthT1(self, text: str, size: float, encoding: str = "utf8") -> float: ...
68
def instanceStringWidthTTF(self, text: str, size: float, encoding: str = "utf8") -> float: ...
79
def hex32(i) -> str: ...
810
def add32(x: int, y: int) -> int: ...
911
def calcChecksum(data: str | bytes) -> int: ...
10-
def escapePDF(s): ...
11-
def asciiBase85Encode(input: str) -> str: ...
12-
def asciiBase85Decode(input): ...
12+
def escapePDF(s) -> LiteralString: ...
13+
def asciiBase85Encode(input: str) -> LiteralString: ...
14+
def asciiBase85Decode(input) -> bytes: ...
1315
def sameFrag(f, g) -> bool | Literal[0]: ...
1416

1517
__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: 162 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,48 @@
11
from _typeshed import Incomplete
2+
from typing_extensions import LiteralString
3+
from weakref import ReferenceType
24

3-
from reportlab.pdfbase.pdfdoc import PDFObject
5+
from reportlab.pdfbase.pdfdoc import PDFDictionary, PDFObject, PDFStream
46

57
__all__ = ("AcroForm",)
68

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

1122
class RadioGroup(PDFObject):
1223
TU: Incomplete
13-
Ff: Incomplete
14-
kids: Incomplete
24+
Ff: int
25+
kids: list[Incomplete]
1526
T: Incomplete
1627
V: Incomplete
1728
def __init__(self, name, tooltip: str = "", fieldFlags: str = "noToggleToOff required radio") -> None: ...
18-
def format(self, doc): ...
29+
def format(self, doc) -> bytes: ...
1930

2031
class AcroForm(PDFObject):
21-
formFontNames: Incomplete
22-
referenceMap: Incomplete
23-
fonts: Incomplete
24-
fields: Incomplete
32+
formFontNames: dict[str, str]
33+
referenceMap: dict[Incomplete, Incomplete]
34+
fonts: dict[str, str]
35+
fields: list[Incomplete]
2536
sigFlags: Incomplete
26-
extras: Incomplete
37+
extras: dict[Incomplete, Incomplete]
2738
def __init__(self, canv, **kwds) -> None: ...
2839
@property
29-
def canv(self): ...
30-
def fontRef(self, f): ...
31-
def format(self, doc): ...
40+
def canv(self) -> ReferenceType[Incomplete]: ...
41+
def fontRef(self, f) -> str: ...
42+
def format(self, doc) -> bytes: ...
3243
def colorTuple(self, c): ...
33-
def streamFillColor(self, c): ...
34-
def streamStrokeColor(self, c): ...
44+
def streamFillColor(self, c) -> LiteralString: ...
45+
def streamStrokeColor(self, c) -> LiteralString: ...
3546
def checkboxAP(
3647
self,
3748
key,
@@ -45,16 +56,16 @@ class AcroForm(PDFObject):
4556
borderStyle: str = "solid",
4657
size: int = 20,
4758
dashLen: int = 3,
48-
): ...
59+
) -> PDFStream: ...
4960
@staticmethod
50-
def circleArcStream(size, r, arcs=(0, 1, 2, 3), rotated: bool = False): ...
51-
def zdMark(self, c, size, ds, iFontName): ...
61+
def circleArcStream(size, r, arcs=(0, 1, 2, 3), rotated: bool = False) -> str: ...
62+
def zdMark(self, c, size, ds, iFontName) -> str: ...
5263
def getRef(self, obj): ...
53-
def getRefStr(self, obj): ...
64+
def getRefStr(self, obj) -> str: ...
5465
@staticmethod
55-
def stdColors(t, b, f): ...
66+
def stdColors(t, b, f) -> tuple[Incomplete, Incomplete, Incomplete]: ...
5667
@staticmethod
57-
def varyColors(key, t, b, f): ...
68+
def varyColors(key, t, b, f) -> tuple[Incomplete, Incomplete, Incomplete]: ...
5869
def checkForceBorder(
5970
self, x, y, width, height, forceBorder, shape, borderStyle, borderWidth, borderColor, fillColor
6071
) -> None: ...
@@ -101,7 +112,7 @@ class AcroForm(PDFObject):
101112
relative: bool = False,
102113
dashLen: int = 3,
103114
) -> None: ...
104-
def makeStream(self, width, height, stream, **D): ...
115+
def makeStream(self, width, height, stream, **D) -> PDFStream: ...
105116
def txAP(
106117
self,
107118
key,
@@ -123,8 +134,8 @@ class AcroForm(PDFObject):
123134
I=[],
124135
sel_bg: str = "0.600006 0.756866 0.854904 rg",
125136
sel_fg: str = "0 g",
126-
): ...
127-
def makeFont(self, fontName): ...
137+
) -> PDFStream: ...
138+
def makeFont(self, fontName: str | None) -> tuple[str, str]: ...
128139
def textfield(
129140
self,
130141
value: str = "",
@@ -144,10 +155,10 @@ class AcroForm(PDFObject):
144155
forceBorder: bool = False,
145156
relative: bool = False,
146157
maxlen: int = 100,
147-
fontName=None,
158+
fontName: str | None = None,
148159
fontSize=None,
149160
dashLen: int = 3,
150-
): ...
161+
) -> None: ...
151162
def listbox(
152163
self,
153164
value: str = "",
@@ -166,12 +177,12 @@ class AcroForm(PDFObject):
166177
fieldFlags: str = "",
167178
forceBorder: bool = False,
168179
relative: bool = False,
169-
fontName=None,
180+
fontName: str | None = None,
170181
fontSize=None,
171182
dashLen: int = 3,
172183
maxlen=None,
173184
options=[],
174-
): ...
185+
) -> None: ...
175186
def choice(
176187
self,
177188
value: str = "",
@@ -190,25 +201,136 @@ class AcroForm(PDFObject):
190201
fieldFlags: str = "combo",
191202
forceBorder: bool = False,
192203
relative: bool = False,
193-
fontName=None,
204+
fontName: str | None = None,
194205
fontSize=None,
195206
dashLen: int = 3,
196207
maxlen=None,
197208
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: ...
209+
) -> None: ...
210+
def checkboxRelative(
211+
self,
212+
*,
213+
checked: bool = False,
214+
buttonStyle: str = "check",
215+
shape: str = "square",
216+
fillColor=None,
217+
borderColor=None,
218+
textColor=None,
219+
borderWidth: int = 1,
220+
borderStyle: str = "solid",
221+
size: int = 20,
222+
x: int = 0,
223+
y: int = 0,
224+
tooltip=None,
225+
name=None,
226+
annotationFlags: str = "print",
227+
fieldFlags: str = "required",
228+
forceBorder: bool = False,
229+
dashLen: int = 3,
230+
) -> None: ...
231+
def radioRelative(
232+
self,
233+
*,
234+
value=None,
235+
selected: bool = False,
236+
buttonStyle: str = "circle",
237+
shape: str = "circle",
238+
fillColor=None,
239+
borderColor=None,
240+
textColor=None,
241+
borderWidth: int = 1,
242+
borderStyle: str = "solid",
243+
size: int = 20,
244+
x: int = 0,
245+
y: int = 0,
246+
tooltip=None,
247+
name=None,
248+
annotationFlags: str = "print",
249+
fieldFlags: str = "noToggleToOff required radio",
250+
forceBorder: bool = False,
251+
dashLen: int = 3,
252+
) -> None: ...
253+
def textfieldRelative(
254+
self,
255+
*,
256+
value: str = "",
257+
fillColor=None,
258+
borderColor=None,
259+
textColor=None,
260+
borderWidth: int = 1,
261+
borderStyle: str = "solid",
262+
width: int = 120,
263+
height: int = 36,
264+
x: int = 0,
265+
y: int = 0,
266+
tooltip=None,
267+
name=None,
268+
annotationFlags: str = "print",
269+
fieldFlags: str = "",
270+
forceBorder: bool = False,
271+
maxlen: int = 100,
272+
fontName: str | None = None,
273+
fontSize=None,
274+
dashLen: int = 3,
275+
) -> None: ...
276+
def listboxRelative(
277+
self,
278+
*,
279+
value: str = "",
280+
fillColor=None,
281+
borderColor=None,
282+
textColor=None,
283+
borderWidth: int = 1,
284+
borderStyle: str = "solid",
285+
width: int = 120,
286+
height: int = 36,
287+
x: int = 0,
288+
y: int = 0,
289+
tooltip=None,
290+
name=None,
291+
annotationFlags: str = "print",
292+
fieldFlags: str = "",
293+
forceBorder: bool = False,
294+
maxlen: int = 100,
295+
fontName: str | None = None,
296+
fontSize=None,
297+
dashLen: int = 3,
298+
) -> None: ...
299+
def choiceRelative(
300+
self,
301+
*,
302+
value: str = "",
303+
fillColor=None,
304+
borderColor=None,
305+
textColor=None,
306+
borderWidth: int = 1,
307+
borderStyle: str = "solid",
308+
width: int = 120,
309+
height: int = 36,
310+
x: int = 0,
311+
y: int = 0,
312+
tooltip=None,
313+
name=None,
314+
annotationFlags: str = "print",
315+
fieldFlags: str = "",
316+
forceBorder: bool = False,
317+
maxlen: int = 100,
318+
fontName: str | None = None,
319+
fontSize=None,
320+
dashLen: int = 3,
321+
) -> None: ...
204322
@property
205-
def encRefStr(self): ...
323+
def encRefStr(self) -> str: ...
206324

207325
class CBMark:
208-
opNames: Incomplete
209-
opCount: Incomplete
326+
opNames: list[str]
327+
opCount: tuple[int, ...]
210328
ops: Incomplete
329+
xmin: Incomplete
330+
ymin: Incomplete
331+
xmax: Incomplete
332+
ymax: Incomplete
211333
points: Incomplete
212334
slack: Incomplete
213335
def __init__(self, ops, points, bounds, slack: float = 0.05) -> None: ...
214-
def scaledRender(self, size, ds: int = 0): ...
336+
def scaledRender(self, size, ds: int = 0) -> str: ...

0 commit comments

Comments
 (0)