code: def hostname_with_port(self):
          '''Return the host portion but omit default port if needed.'''
          default_port = RELATIVE_SCHEME_DEFAULT_PORTS.get(self.scheme)
          if not default_port:
              return ''
  
          assert '[' not in self.hostname
          assert ']' not in self.hostname
  
          if self.is_ipv6():
              hostname = '[{}]'.format(self.hostname)
          else:
              hostname = self.hostname
  
          if default_port != self.port:
              return '{}:{}'.format(hostname, self.port)
          else:
              return hostnamf hostname_with_port(self):
          '''Return the host portion but omit default port if needed.'''
          default_port = RELATIVE_SCHEME_DEFAULT_PORTS.get(self.scheme)
          if not default_port:
              return ''
  
          assert '[' not in self.hostname
          assert ']' not in self.hostname
  
          if self.is_ipv6():
              hostname = '[{}]'.format(self.hostname)
          else:
              hostname = self.hostname
  
          if default_port != self.port:
              return '{}:{}'.format(hostname, self.port)
          else:
              return hostname
docs: Return the host portion but omit default port if needed.