Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mypy errors on Twisted 24.11.0 #17998

Merged
merged 5 commits into from
Dec 18, 2024

Conversation

anoadragon453
Copy link
Member

Fixes various mypy errors associated with Twisted 24.11.0.

Hopefully addresses #17075, though I've yet to test against trunk.

Changes should be compatible with our currently pinned Twisted version of 24.7.0.

resolveHostName wanted an instance of a type. We also had to switch from provider to
implementer, as the latter implies that any instances implement the given interface.

Fixed the following error:

synapse/http/client.py:243: error: Argument 1 to "resolveHostName" of "IHostnameResolver" has incompatible type "type[EndpointReceiver]"; expected "IResolutionReceiver"  [arg-type]
mypy would not accept passing a **kwargs to `HostnameEndpoint`.

Resolves the following errors:

 synapse/http/proxyagent.py:385: error: Argument 4 to "HostnameEndpoint" has incompatible type "**dict[str, object]"; expected "float"  [arg-type]
synapse/http/proxyagent.py:385: error: Argument 4 to "HostnameEndpoint" has incompatible type "**dict[str, object]"; expected "Union[bytes, str, tuple[Union[bytes, str], int], None]"  [arg-type]
synapse/http/proxyagent.py:385: error: Argument 4 to "HostnameEndpoint" has incompatible type "**dict[str, object]"; expected "Optional[float]"  [arg-type]
`._hostStr` was replaced with `._hostText` in twisted/twisted#12351

Resolves the following errors:

tests/http/test_proxyagent.py:857: error: "HostnameEndpoint" has no attribute "_hostStr"  [attr-defined]
tests/http/test_proxyagent.py:869: error: "HostnameEndpoint" has no attribute "_hostStr"  [attr-defined]
just mypy being particular about changing the type of an already-defined variable.

Resolves the following mypy errors:

synapse/http/replicationagent.py:92: error: Incompatible types in assignment (expression has type "_WrapperEndpoint", variable has type "HostnameEndpoint")  [assignment]
synapse/http/proxyagent.py:394: error: Incompatible types in assignment (expression has type "_WrapperEndpoint", variable has type "HostnameEndpoint")  [assignment]
@anoadragon453 anoadragon453 changed the title pass an instance, not a type, to resolveHostName Fix mypy errors on Twisted 24.11.0 Dec 4, 2024
@anoadragon453 anoadragon453 marked this pull request as ready for review December 4, 2024 18:51
@anoadragon453 anoadragon453 requested a review from a team as a code owner December 4, 2024 18:51
@anoadragon453 anoadragon453 merged commit 3eb9236 into develop Dec 18, 2024
39 checks passed
@anoadragon453 anoadragon453 deleted the anoa/fix_mypy_errors_latest_twisted branch December 18, 2024 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants