Is there a way to detect when running in a with ipywidgets.Output() block?

I have a library that uses IPython.display.HTML and it works great for most users. However, when a user wants to use with ipywidgets.Output(), it would be better to use ipywidgets.HTML. Is there a way to detect when this is occurring?

To clarify:

import ipywidgets

def in_output_block():
    # What goes here?

out = ipywidgets.Output()

with out:
   assert in_output_block() is True

assert in_output_block() is False