Skip to content

Commit 0ac3708

Browse files
AdrianSosicRimRihana
authored andcommitted
Fix validation logic
1 parent 388b2b6 commit 0ac3708

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

baybe/utils/basic.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,18 @@ def register_hook(target: Callable, hook: Callable) -> Callable:
208208
)
209209

210210
for p1, p2 in zip(target_params, hook_params):
211-
if p1.name != p2.name or p1.annotation != p2.annotation:
212-
if p2.annotation is not inspect.Parameter.empty:
213-
raise TypeError(
214-
f"The signature of '{hook.__name__}' does not match the "
215-
f"signature of '{target.__name__}'."
216-
)
211+
if p1.name != p2.name:
212+
raise TypeError(
213+
f"The parameter names of '{target.__name__}' "
214+
f"and '{hook.__name__}' do not match."
215+
)
216+
if (p1.annotation != p2.annotation) and (
217+
p2.annotation is not inspect.Parameter.empty
218+
):
219+
raise TypeError(
220+
f"The type annotations of '{target.__name__}' "
221+
f"and '{hook.__name__}' do not match."
222+
)
217223

218224
@functools.wraps(target)
219225
def wraps(*args, **kwargs):

0 commit comments

Comments
 (0)