code: def has_unclosed_brackets(text):
      
      stack = []
  
      # Ignore braces inside strings
      text = re.sub(r'''('[^']*'|"[^"]*")''', '', text)  # XXX: handle escaped quotes.!
  
      for c in reversed(text):
          if c in '])}':
              stack.append(c)
  
          elif c in '[({':
              if stack:
                  if ((c == '[' and stack[-1] == ']') or
                          (c == '{' and stack[-1] == '}') or
                          (c == '(' and stack[-1] == ')')):
                      stack.pop()
              else:
                  # Opening bracket for which we didn't had a closing one.
                  return True
  
      return False
docs: Starting at the end of the string. If we find an opening bracket
      for which we didn't had a closing one yet, return True.