Aye, I do, and it should be "raise NotImplementedError('Explanation of
the failed check')"
Rationale:
- Python isn't C or Go, so we indicate failures with exceptions, not
error codes (NotImplemented is an necessary performance hack for
operand coercion in tight loops, not an example to be emulated in
other APIs)
- allows the backend to provide information on what went wrong
- means an unhandled backend error results in a traceback pointing to
where the build failed, not some later point in the frontend code
- if a backend developer is sufficiently worried about accidentally
propagating NotImplementedError that they want to pretend they're not
writing Python any more, they can use this idiom:
def public_hook_api(*args, **kwds):
try:
result, error_msg = _internal_hook_implementation(*args, **kwds)
except NotImplementedError as exc:
raise RuntimeError("Unexpected NotImplementedError") from exc
if result is NotImplemented:
raise NotImplementedError(error_msg)
return result
That provides the backend with all the same assurances against
accidentally letting NotImplementedError escape that a return code
based public API would, without frontends even needing to be aware of
the backend developer's aversion to reporting errors as exceptions.