We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f4f70b5 commit ca787c3Copy full SHA for ca787c3
pydentification/stubs.py
@@ -9,6 +9,8 @@ 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
def cast(arg: Any, hint: Any) -> Any:
16
if hint == Union[str, Path]:
@@ -21,6 +23,9 @@ def wrapper(*args, **kwargs):
21
23
new_args = []
22
24
new_kwargs = {}
25
26
+ if len(args) + len(kwargs) > len(hints):
27
+ raise TypeError("Some arguments are missing type hints!")
28
29
for arg, (name, hint) in zip(args, hints.items()):
30
new_args.append(cast(arg, hint))
31
for name, arg in kwargs.items():
0 commit comments