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

Create a mypy plugin for replication class methods #8828

Open
matrixbot opened this issue Dec 18, 2023 · 0 comments
Open

Create a mypy plugin for replication class methods #8828

matrixbot opened this issue Dec 18, 2023 · 0 comments

Comments

@matrixbot
Copy link
Collaborator

matrixbot commented Dec 18, 2023

This issue has been migrated from #8828.


Replication servlet classes, such as ReplicationRemoteJoinRestServlet, ReplicationUserDevicesResyncRestServlet etc. each have _serialize_payload and _handle_request methods. Traditionally we haven't added typing to these methods as it breaks mypy for two reasons:

If types are added to any instance of _serialize_payload or _handle_request, mypy will complain about this discrepancy, and thus an # type: ignore has typically been put on the method signature in order to avoid this:

https://github.com/matrix-org/synapse/blob/377673db2ac4b4af6a237252dc39cf464cfb3a30/synapse/replication/http/membership.py#L55-L62

A better solution is to write a mypy plugin, much like we already have for cache functions to properly check the types and remove the need to ignore them.

Note that this issue grew out of a discussion here: matrix-org/synapse#8809 (comment)

@matrixbot matrixbot changed the title Dummy issue Create a mypy plugin for replication class methods Dec 21, 2023
@matrixbot matrixbot reopened this Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant