code: def expanded(self):
          
          # Ensure we can run outside a application/request context.
          if request:
              if 'expanded' in request.args:
                  return True
              elif 'compacted' in request.args:
                  return False
          return self._expanded
docs: Get JSON-LD expanded state.