code: def maybe_ip_addr(addr):
      
  
      if six.PY2 and isinstance(addr, str):
          addr = unicode(addr)  # noqa
      try:
          return ipaddress.ip_address(addr)
      except ValueError:
          pass
      return str(addr)
docs: Tries to return an IPAddress, otherwise returns a string.
  
      TODO consider explicitly checking for .exit or .onion at the end?