code: def with_port(self, port):
          
          # N.B. doesn't cleanup query/fragment
          if port is not None and not isinstance(port, int):
              raise TypeError("port should be int or None, got {}".format(type(port)))
          if not self.is_absolute():
              raise ValueError("port replacement is not allowed " "for relative URLs")
          val = self._val
          return URL(
              self._val._replace(
                  netloc=self._make_netloc(
                      val.username, val.password, val.hostname, port, encode=False
                  )
              ),
              encoded=True,
          )
docs: Return a new URL with port replaced.
  
          Clear port to default if None is passed.