Skip to content

Commit 501981b

Browse files
committed
Fixed type annotations in pagesizes
1 parent cc2cf50 commit 501981b

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

domdf_python_tools/pagesizes/classes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def __new__(cls, width: AnyNumber, height: AnyNumber, unit: AnyNumber = pt):
319319
:param unit:
320320
"""
321321

322-
width, height = convert_from((width, height), unit)
322+
width, height = convert_from((width, height), unit) # type: ignore
323323
return super().__new__(cls, width, height)
324324

325325
@property

domdf_python_tools/pagesizes/utils.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,25 @@
3636
# stdlib
3737
import re
3838
from decimal import Decimal
39-
from typing import Sequence, Tuple, Union
39+
from typing import Sequence, Tuple, Union, overload
4040

4141
# this package
4242
from ._types import AnyNumber
43-
from .units import cc, cm, dd, inch, mm, nc, nd, pc, pica, sp, um
43+
from .units import cc, cm, dd, inch, mm, nc, nd, pc, pica, pt, sp, um
4444

4545
# from .units import Unit
4646

4747
__all__ = ["convert_from", "parse_measurement"]
4848

4949

50+
@overload
51+
def convert_from(value: Sequence[AnyNumber], from_: AnyNumber) -> Tuple[float, ...]: ...
52+
53+
54+
@overload
55+
def convert_from(value: AnyNumber, from_: AnyNumber) -> float: ...
56+
57+
5058
def convert_from(
5159
value: Union[Sequence[AnyNumber], AnyNumber],
5260
from_: AnyNumber,
@@ -101,7 +109,7 @@ def parse_measurement(measurement: str) -> Union[float, Tuple[float, ...]]:
101109
elif unit in {"um", "μm", "µm"}:
102110
return convert_from(val, um)
103111
elif unit == "pt":
104-
return val
112+
return convert_from(val, pt)
105113
elif unit == "inch":
106114
return convert_from(val, inch)
107115
elif unit == "in":

0 commit comments

Comments
 (0)