You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the existing issues and didn't find my feature already requested there
Feature description
Currently typecheck_fail_callback can only be used for side effects. I am proposing that it should also be able to return a value and that check_type would then return that value.
Use case
This lets us replace this:
x = None
try:
check_type(<value>, <type>)
except TypeCheckError as err:
x = some_function(err, z)
with the much cleaner and more elegant:
x = check_type(<value>, <type>, typecheck_fail_callback= partial(some_function, arg=z)
The text was updated successfully, but these errors were encountered:
Things to check first
Feature description
Currently typecheck_fail_callback can only be used for side effects. I am proposing that it should also be able to return a value and that check_type would then return that value.
Use case
This lets us replace this:
with the much cleaner and more elegant:
The text was updated successfully, but these errors were encountered: