Skip to content

Commit 326d1f4

Browse files
committed
Keep callable validation on its declaration path
1 parent ee2b812 commit 326d1f4

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

‎src/python_introspect/validation.py‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ def validate_annotation_value(
148148
_validate_mapping(annotation, value, path)
149149
return
150150
if origin is Callable:
151-
_validate_callable(value, path)
151+
if not callable(value):
152+
raise TypeError(f"{path} must be callable; got {type(value).__name__}.")
152153
return
153154
if origin is ClassVar:
154155
return
@@ -217,11 +218,6 @@ def _validate_mapping(annotation: object, value: object, path: str) -> None:
217218
validate_annotation_value(item_type, item, path=f"{path}[{key!r}]")
218219

219220

220-
def _validate_callable(value: object, path: str) -> None:
221-
if not callable(value):
222-
raise TypeError(f"{path} must be callable; got {type(value).__name__}.")
223-
224-
225221
def _annotation_label(annotation: object) -> str:
226222
return annotation.__name__ if isinstance(annotation, type) else str(annotation)
227223

0 commit comments

Comments
 (0)