Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The sandbox method of evaluating and rendering ehrql objects was via
monkey patching various repr functions The initial debug implementation
re-used this method, and manually called
repr()
from within the show()call.
Now that we don't have a sandbox, all rendering can be done explicitly
by the show() function, so there is no need for repr monkey patching.
This refactor switches the evaluate/render steps to be done explicitly
in show(), rather than going via repr.
However, the repr monkey patching implementation used a closure to
capture the supplied renderer and engine details in the monkeypatched
function. As
show()
is a user imported static function, it cannot usea closure. Instead, we formalize the DEBUG_QUERY_ENGINE global into
a new DEBUG_CONTEXT global, which is set via
activate_debug_context
,and then available to use inside
show()
. This DEBUG_CONTEXT stores theengine instance and the renderer, and knows how to render and object
with those.