This `if` is mutually exclusive from the preceding `if`, correct? Maybe better to write it as an `elif`.

I'd write it as...

```python
...
scheme, host, port = get_host(url)
default_port = port_by_scheme.get(scheme)

# Normalize explicit default port for comparison.
if self.port and not port:
    port = default_port
elif not self.port and port == default_port:
    port = None
```

Feels like this could be expressed even simpler, but the solution evades me at the moment. :)