Commit e77b9299 authored by Chris Lamb's avatar Chris Lamb 💬

diffoscope.tools: Add internal documentation for @tool_required decorator.

Signed-off-by: Chris Lamb's avatarChris Lamb <lamby@debian.org>
parent 140aefd1
......@@ -52,6 +52,16 @@ def tool_required(command):
def wrapper(fn):
@functools.wraps(fn)
def tool_check(*args, **kwargs):
"""
Due to the way decorators are executed at import-time we defer the
execution of `find_executable` until we actually run the decorated
function (instead of prematurely returning a different version of
`tool_check`).
This ensures that any os.environ['PATH'] modifications are
performed prior to the `find_executable` tests.
"""
if not find_executable(command):
raise RequiredToolNotFound(command)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment