Skip to content

Commit ca787c3

Browse files
committed
[stubs](chore) Add safety check
1 parent f4f70b5 commit ca787c3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pydentification/stubs.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ def cast_to_path(func: Callable):
99
"""
1010
Decorator to cast string arguments to Path in the function signature.
1111
Uses type hints to determine which arguments should be cast.
12+
13+
:note: do not use with functions that have missing type hints
1214
"""
1315
def cast(arg: Any, hint: Any) -> Any:
1416
if hint == Union[str, Path]:
@@ -21,6 +23,9 @@ def wrapper(*args, **kwargs):
2123
new_args = []
2224
new_kwargs = {}
2325

26+
if len(args) + len(kwargs) > len(hints):
27+
raise TypeError("Some arguments are missing type hints!")
28+
2429
for arg, (name, hint) in zip(args, hints.items()):
2530
new_args.append(cast(arg, hint))
2631
for name, arg in kwargs.items():

0 commit comments

Comments
 (0)