|
36 | 36 | # stdlib |
37 | 37 | import re |
38 | 38 | from decimal import Decimal |
39 | | -from typing import Sequence, Tuple, Union |
| 39 | +from typing import Sequence, Tuple, Union, overload |
40 | 40 |
|
41 | 41 | # this package |
42 | 42 | 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 |
44 | 44 |
|
45 | 45 | # from .units import Unit |
46 | 46 |
|
47 | 47 | __all__ = ["convert_from", "parse_measurement"] |
48 | 48 |
|
49 | 49 |
|
| 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 | + |
50 | 58 | def convert_from( |
51 | 59 | value: Union[Sequence[AnyNumber], AnyNumber], |
52 | 60 | from_: AnyNumber, |
@@ -101,7 +109,7 @@ def parse_measurement(measurement: str) -> Union[float, Tuple[float, ...]]: |
101 | 109 | elif unit in {"um", "μm", "µm"}: |
102 | 110 | return convert_from(val, um) |
103 | 111 | elif unit == "pt": |
104 | | - return val |
| 112 | + return convert_from(val, pt) |
105 | 113 | elif unit == "inch": |
106 | 114 | return convert_from(val, inch) |
107 | 115 | elif unit == "in": |
|
0 commit comments