Skip to content

Commit 1b3cec1

Browse files
authored
[reportlab] Add more annotations for lib (#15426)
1 parent 6e7ee0e commit 1b3cec1

20 files changed

+235
-201
lines changed
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1+
import re
12
from _typeshed import Incomplete
23
from typing import Final
34

45
__version__: Final[str]
56

67
def replace(src, sep, rep): ...
78

8-
keywordsList: Incomplete
9+
keywordsList: list[str]
910
commentPat: str
1011
pat: str
11-
quotePat: Incomplete
12-
tripleQuotePat: Incomplete
12+
quotePat: str
13+
tripleQuotePat: str
1314
nonKeyPat: str
14-
keyPat: Incomplete
15-
matchPat: Incomplete
16-
matchRE: Incomplete
15+
keyPat: str
16+
matchPat: str
17+
matchRE: re.Pattern[str]
1718
idKeyPat: str
18-
idRE: Incomplete
19+
idRE: re.Pattern[str]
1920

20-
def fontify(pytext, searchfrom: int = 0, searchto=None): ...
21+
def fontify(pytext, searchfrom: int = 0, searchto=None) -> list[tuple[str, int, int, Incomplete]]: ...
2122
def test(path) -> None: ...
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
class ArcIV:
22
def __init__(self, key) -> None: ...
33
def reset(self) -> None: ...
4-
def encode(self, S): ...
4+
def encode(self, S: str | bytes | list[int]) -> bytes: ...
55

6-
def encode(text, key): ...
7-
def decode(text, key): ...
6+
def encode(text: str | bytes | list[int], key) -> bytes: ...
7+
def decode(text: str | bytes | list[int], key) -> bytes: ...
88

99
__all__ = ["ArcIV", "encode", "decode"]

stubs/reportlab/reportlab/lib/attrmap.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class AttrMapValue:
1919
class AttrMap(dict[str, AttrMapValue]):
2020
def __init__(self, BASE=None, UNWANTED=[], **kw) -> None: ...
2121
def remove(self, unwanted) -> None: ...
22-
def clone(self, UNWANTED=[], **kw): ...
22+
def clone(self, UNWANTED=[], **kw) -> AttrMap: ...
2323

2424
def validateSetattr(obj, name, value) -> None: ...
25-
def hook__setattr__(obj): ...
25+
def hook__setattr__(obj) -> None: ...
2626
def addProxyAttribute(src, name, validate=None, desc=None, initial=None, dst=None) -> None: ...
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
from typing import Final
1+
from _typeshed import Incomplete
2+
from typing import Final, Literal, overload
23

34
__version__: Final[str]
45

5-
def rectCorner(x, y, width, height, anchor: str = "sw", dims: bool = False): ...
6-
def aspectRatioFix(preserve, anchor, x, y, width, height, imWidth, imHeight, anchorAtXY: bool = False): ...
6+
@overload
7+
def rectCorner(
8+
x, y, width, height, anchor: str = "sw", dims: Literal[True] = ...
9+
) -> tuple[Incomplete, Incomplete, Incomplete, Incomplete]: ...
10+
@overload
11+
def rectCorner(x, y, width, height, anchor: str = "sw", dims: Literal[False] | None = False) -> tuple[Incomplete, Incomplete]: ...
12+
def aspectRatioFix(
13+
preserve, anchor, x, y, width, height, imWidth, imHeight, anchorAtXY: bool = False
14+
) -> tuple[Incomplete, Incomplete, Incomplete, Incomplete, Incomplete]: ...

stubs/reportlab/reportlab/lib/codecharts.pyi

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from _typeshed import Incomplete
22
from typing import Final
33

4+
from reportlab.graphics.shapes import Group
45
from reportlab.graphics.widgetbase import Widget
56
from reportlab.platypus import Flowable
67

78
__version__: Final[str]
8-
adobe2codec: Incomplete
9+
adobe2codec: dict[str, str]
910

1011
class CodeChartBase(Flowable):
1112
rows: Incomplete
@@ -14,7 +15,7 @@ class CodeChartBase(Flowable):
1415
ylist: Incomplete
1516
xlist: Incomplete
1617
def calcLayout(self) -> None: ...
17-
def formatByte(self, byt): ...
18+
def formatByte(self, byt) -> str: ...
1819
def drawChars(self, charList) -> None: ...
1920
def drawLabels(self, topLeft: str = "") -> None: ...
2021

@@ -35,7 +36,7 @@ class SingleByteEncodingChart(CodeChartBase):
3536
boxSize: int = 14,
3637
hex: int = 1,
3738
) -> None: ...
38-
def draw(self): ...
39+
def draw(self) -> None: ...
3940

4041
class KutenRowCodeChart(CodeChartBase):
4142
row: Incomplete
@@ -49,7 +50,7 @@ class KutenRowCodeChart(CodeChartBase):
4950
encodingName: Incomplete
5051
fontName: Incomplete
5152
def __init__(self, row, faceName, encodingName) -> None: ...
52-
def makeRow(self, row): ...
53+
def makeRow(self, row) -> list[bytes | list[None]]: ...
5354
def draw(self) -> None: ...
5455

5556
class Big5CodeChart(CodeChartBase):
@@ -64,7 +65,7 @@ class Big5CodeChart(CodeChartBase):
6465
rowLabels: Incomplete
6566
fontName: Incomplete
6667
def __init__(self, row, faceName, encodingName) -> None: ...
67-
def makeRow(self, row): ...
68+
def makeRow(self, row) -> list[bytes | list[None]]: ...
6869
def draw(self) -> None: ...
6970

7071
def hBoxText(msg, canvas, x, y, fontName) -> None: ...
@@ -75,6 +76,6 @@ class CodeWidget(Widget):
7576
width: int
7677
height: int
7778
def __init__(self) -> None: ...
78-
def draw(self): ...
79+
def draw(self) -> Group: ...
7980

8081
def test() -> None: ...

stubs/reportlab/reportlab/lib/corp.pyi

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Iterable
23
from typing import Final
34

5+
from reportlab.graphics.shapes import Drawing, Group
46
from reportlab.graphics.widgetbase import Widget
57
from reportlab.lib.attrmap import *
68
from reportlab.lib.validators import *
@@ -24,10 +26,10 @@ class RL_CorpLogo(Widget):
2426
pageColors: Incomplete
2527
prec: Incomplete
2628
def __init__(self) -> None: ...
27-
def demo(self): ...
29+
def demo(self) -> Drawing: ...
2830
@staticmethod
2931
def applyPrec(P, prec): ...
30-
def draw(self): ...
32+
def draw(self) -> Group: ...
3133

3234
class RL_CorpLogoReversed(RL_CorpLogo):
3335
background: Incomplete
@@ -42,8 +44,8 @@ class RL_CorpLogoThin(Widget):
4244
height: Incomplete
4345
width: Incomplete
4446
def __init__(self) -> None: ...
45-
def demo(self): ...
46-
def draw(self): ...
47+
def demo(self) -> Drawing: ...
48+
def draw(self) -> Group: ...
4749

4850
class ReportLabLogo:
4951
origin: Incomplete
@@ -73,7 +75,7 @@ class RL_BusinessCard(Widget):
7375
web: str
7476
rh_blurb_top: Incomplete
7577
def __init__(self) -> None: ...
76-
def demo(self): ...
77-
def draw(self): ...
78+
def demo(self) -> Drawing: ...
79+
def draw(self) -> Group: ...
7880

79-
def test(formats=["pdf", "eps", "jpg", "gif", "svg"]) -> None: ...
81+
def test(formats: Iterable[str] = ["pdf", "eps", "jpg", "gif", "svg"]) -> None: ...
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
from typing import Final
1+
from collections.abc import Mapping
2+
from typing import Any, Final
23

34
__version__: Final[str]
45

5-
def dictformat(_format, L={}, G={}): ...
6-
def magicformat(format): ...
6+
def dictformat(
7+
_format: str, L: Mapping[str, object] | None = {}, G: dict[str, Any] | None = {} # `L` and `G` are passed to `eval` function
8+
) -> str: ...
9+
def magicformat(format: str) -> str: ...

stubs/reportlab/reportlab/lib/fontfinder.pyi

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
from _typeshed import Incomplete
22
from typing import Final
3+
from typing_extensions import LiteralString
34

45
__version__: Final[str]
56

6-
def asNative(s): ...
7+
def asNative(s) -> str: ...
78

8-
EXTENSIONS: Incomplete
9-
FF_FIXED: Incomplete
10-
FF_SERIF: Incomplete
11-
FF_SYMBOLIC: Incomplete
12-
FF_SCRIPT: Incomplete
13-
FF_NONSYMBOLIC: Incomplete
14-
FF_ITALIC: Incomplete
15-
FF_ALLCAP: Incomplete
16-
FF_SMALLCAP: Incomplete
17-
FF_FORCEBOLD: Incomplete
9+
EXTENSIONS: Final = [".ttf", ".ttc", ".otf", ".pfb", ".pfa"]
10+
FF_FIXED: Final = 1
11+
FF_SERIF: Final = 2
12+
FF_SYMBOLIC: Final = 4
13+
FF_SCRIPT: Final = 8
14+
FF_NONSYMBOLIC: Final = 32
15+
FF_ITALIC: Final = 64
16+
FF_ALLCAP: Final = 65536
17+
FF_SMALLCAP: Final = 131072
18+
FF_FORCEBOLD: Final = 262144
1819

1920
class FontDescriptor:
2021
name: Incomplete
@@ -30,7 +31,7 @@ class FontDescriptor:
3031
metricsFileName: Incomplete
3132
timeModified: int
3233
def __init__(self) -> None: ...
33-
def getTag(self): ...
34+
def getTag(self) -> LiteralString: ...
3435

3536
class FontFinder:
3637
useCache: Incomplete
@@ -41,11 +42,11 @@ class FontFinder:
4142
) -> None: ...
4243
def addDirectory(self, dirName, recur=None) -> None: ...
4344
def addDirectories(self, dirNames, recur=None) -> None: ...
44-
def getFamilyNames(self): ...
45+
def getFamilyNames(self) -> list[bytes]: ...
4546
def getFontsInFamily(self, familyName): ...
46-
def getFamilyXmlReport(self): ...
47-
def getFontsWithAttributes(self, **kwds): ...
48-
def getFont(self, familyName, bold: bool = False, italic: bool = False): ...
47+
def getFamilyXmlReport(self) -> LiteralString: ...
48+
def getFontsWithAttributes(self, **kwds) -> list[FontDescriptor]: ...
49+
def getFont(self, familyName, bold: bool = False, italic: bool = False) -> FontDescriptor: ...
4950
def save(self, fileName) -> None: ...
5051
def load(self, fileName) -> None: ...
5152
def search(self) -> None: ...
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
from _typeshed import Incomplete
2+
from typing import Literal
3+
from typing_extensions import LiteralString
24

35
class Formatter:
4-
pattern: Incomplete
5-
def __init__(self, pattern) -> None: ...
6-
def format(self, obj): ...
7-
def __call__(self, x): ...
6+
pattern: str
7+
def __init__(self, pattern: str) -> None: ...
8+
def format(self, obj: object) -> str: ...
9+
def __call__(self, x: object) -> str: ...
810

911
class DecimalFormatter(Formatter):
1012
calcPlaces: Incomplete
11-
places: Incomplete
13+
places: int
1214
dot: Incomplete
1315
comma: Incomplete
1416
prefix: Incomplete
1517
suffix: Incomplete
16-
def __init__(self, places: int = 2, decimalSep: str = ".", thousandSep=None, prefix=None, suffix=None) -> None: ...
17-
def format(self, num): ...
18+
def __init__(
19+
self, places: int | Literal["auto"] = 2, decimalSep: str = ".", thousandSep=None, prefix=None, suffix=None
20+
) -> None: ...
21+
def format(self, num) -> LiteralString: ...
1822

1923
__all__ = ("Formatter", "DecimalFormatter")

stubs/reportlab/reportlab/lib/geomutils.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ from typing import Final
22

33
__version__: Final[str]
44

5-
def normalizeTRBL(p): ...
5+
def normalizeTRBL(p: float | tuple[float, ...] | list[float]) -> tuple[float, ...]: ...

0 commit comments

Comments
 (0)