code: def get_flags(self, i, scoped=False):
          
  
          if scoped and not _SCOPED_FLAG_SUPPORT:
              return None
  
          index = i.index
          value = ['(']
          toggle = False
          end = ':' if scoped else ')'
          try:
              c = next(i)
              if c != '?':
                  i.rewind(1)
                  return None
              value.append(c)
              c = next(i)
              while c != end:
                  if toggle:
                      if c not in _SCOPED_FLAGS:
                          raise ValueError('Bad scope')
                      toggle = False
                  elif scoped and c == '-':
                      toggle = True
                  elif not _util.PY37 and scoped and c in _GLOBAL_FLAGS:
                      raise ValueError("Bad flag")
                  elif c not in _GLOBAL_FLAGS and c not in _SCOPED_FLAGS:
                      raise ValueError("Bad flag")
                  value.append(c)
                  c = next(i)
              value.append(c)
          except Exception:
              i.rewind(i.index - index)
              value = []
  
          return ''.join(value) if value else None
docs: Get flags.