Skip to content

Commit bf1d894

Browse files
authored
types(promotion): add typing to convert (#202)
* types(promotion): add typing to convert Signed-off-by: Nathaniel Starkman <[email protected]> * config(coverage): configure to ignore type-checking Signed-off-by: Nathaniel Starkman <[email protected]> --------- Signed-off-by: Nathaniel Starkman <[email protected]>
1 parent bad8ae6 commit bf1d894

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

plum/promotion.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"promote",
99
]
1010

11-
from typing import Callable, Protocol, Type, TypeVar
11+
from typing import TYPE_CHECKING, Any, Callable, Protocol, Type, TypeVar
12+
13+
from typing_extensions import TypeAlias
1214

1315
from beartype.door import TypeHint
1416

@@ -21,11 +23,18 @@
2123
T = TypeVar("T")
2224
R = TypeVar("R")
2325

26+
if TYPE_CHECKING:
27+
TypeTo = TypeVar("TypeTo")
28+
typeTypeTo: TypeAlias = type[TypeTo]
29+
else:
30+
TypeTo = Any
31+
typeTypeTo = Any
32+
2433
_dispatch = Dispatcher()
2534

2635

2736
@_dispatch
28-
def convert(obj, type_to):
37+
def convert(obj: object, type_to: typeTypeTo) -> TypeTo:
2938
"""Convert an object to a particular type.
3039
3140
Args:

pyproject.toml

+9-4
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,15 @@ build.hooks.vcs.version-file = "plum/_version.py"
6060

6161

6262
# Development tools
63-
[tool.coverage.run]
64-
branch = true
65-
command_line = "-m pytest --verbose test"
66-
source = ["plum"]
63+
[tool.coverage]
64+
run.branch = true
65+
run.command_line = "-m pytest --verbose test"
66+
run.source = ["plum"]
67+
report.exclude_also = [
68+
'\.\.\.',
69+
'if TYPE_CHECKING:',
70+
'if typing.TYPE_CHECKING:',
71+
]
6772

6873
[tool.pytest.ini_options]
6974
testpaths = ["tests/", "plum", "docs"]

0 commit comments

Comments
 (0)