Skip to content

Commit c3fead8

Browse files
feat: add source code path for helping developer targeting problematic code
1 parent 9f6f626 commit c3fead8

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

py_spring/core/utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ def check_type_hints_for_callable(func: Callable[..., Any]) -> None:
8989
func_name = func.__name__
9090
args_type_hints = get_type_hints(func)
9191
arg_type = inspect.getargs(func.__code__)
92-
92+
code_path = inspect.getsourcefile(func)
9393
if RETURN_ID not in args_type_hints:
9494
raise TypeHintError(
95-
f"Type hints for 'return type' not provided for the function: {class_name}.{func_name}"
95+
f"Type hints for 'return type' not provided for the function: {class_name}.{func_name}, path: {code_path}"
9696
)
9797

9898
# plue one is for return type, return type is not included in co_argcount if it is a simple function,
@@ -103,7 +103,7 @@ def check_type_hints_for_callable(func: Callable[..., Any]) -> None:
103103
return
104104
if len(args_type_hints) == 0:
105105
raise TypeHintError(
106-
f"Type hints not provided for the function: {class_name}.{func_name}, arguments: {arguments}, current type hints: {args_type_hints}"
106+
f"Type hints not provided for the function: {class_name}.{func_name}, arguments: {arguments}, current type hints: {args_type_hints}, path: {code_path}"
107107
)
108108

109109
if len(args_type_hints) != argument_count:
@@ -112,9 +112,8 @@ def check_type_hints_for_callable(func: Callable[..., Any]) -> None:
112112
]
113113
if len(missing_type_hints_args) == 0:
114114
return
115-
116115
raise TypeHintError(
117-
f"Type hints not fully provided: {class_name}.{func_name}, arguments: {arguments}, current type hints: {args_type_hints}, missingg type hints: {','.join(missing_type_hints_args)}"
116+
f"Type hints not fully provided: {class_name}.{func_name}, arguments: {arguments}, current type hints: {args_type_hints}, missingg type hints: {','.join(missing_type_hints_args)}, path: {code_path}"
118117
)
119118

120119

0 commit comments

Comments
 (0)