Skip to content

Commit

Permalink
types(promotion): add typing to convert (#202)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
nstarman authored Jan 7, 2025
1 parent bad8ae6 commit bf1d894
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
13 changes: 11 additions & 2 deletions plum/promotion.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"promote",
]

from typing import Callable, Protocol, Type, TypeVar
from typing import TYPE_CHECKING, Any, Callable, Protocol, Type, TypeVar

from typing_extensions import TypeAlias

from beartype.door import TypeHint

Expand All @@ -21,11 +23,18 @@
T = TypeVar("T")
R = TypeVar("R")

if TYPE_CHECKING:
TypeTo = TypeVar("TypeTo")
typeTypeTo: TypeAlias = type[TypeTo]
else:
TypeTo = Any
typeTypeTo = Any

_dispatch = Dispatcher()


@_dispatch
def convert(obj, type_to):
def convert(obj: object, type_to: typeTypeTo) -> TypeTo:
"""Convert an object to a particular type.
Args:
Expand Down
13 changes: 9 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,15 @@ build.hooks.vcs.version-file = "plum/_version.py"


# Development tools
[tool.coverage.run]
branch = true
command_line = "-m pytest --verbose test"
source = ["plum"]
[tool.coverage]
run.branch = true
run.command_line = "-m pytest --verbose test"
run.source = ["plum"]
report.exclude_also = [
'\.\.\.',
'if TYPE_CHECKING:',
'if typing.TYPE_CHECKING:',
]

[tool.pytest.ini_options]
testpaths = ["tests/", "plum", "docs"]
Expand Down

0 comments on commit bf1d894

Please sign in to comment.