We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f4f70b5 commit 6f59db8Copy full SHA for 6f59db8
pydentification/stubs.py
@@ -9,7 +9,10 @@ def cast_to_path(func: Callable):
9
"""
10
Decorator to cast string arguments to Path in the function signature.
11
Uses type hints to determine which arguments should be cast.
12
+
13
+ :note: do not use with functions that have missing type hints
14
15
16
def cast(arg: Any, hint: Any) -> Any:
17
if hint == Union[str, Path]:
18
return Path(arg)
@@ -21,6 +24,9 @@ def wrapper(*args, **kwargs):
21
24
new_args = []
22
25
new_kwargs = {}
23
26
27
+ if len(args) + len(kwargs) > len(hints):
28
+ raise TypeError("Some arguments are missing type hints!")
29
30
for arg, (name, hint) in zip(args, hints.items()):
31
new_args.append(cast(arg, hint))
32
for name, arg in kwargs.items():
0 commit comments