Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Create a mypy plugin for replication class methods #8828

Open
anoadragon453 opened this issue Nov 26, 2020 · 0 comments
Open

Create a mypy plugin for replication class methods #8828

anoadragon453 opened this issue Nov 26, 2020 · 0 comments
Labels
T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks. Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution z-p3 (Deprecated Label)

Comments

@anoadragon453
Copy link
Member

anoadragon453 commented Nov 26, 2020

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:

@staticmethod
async def _serialize_payload( # type: ignore
requester: Requester,
room_id: str,
user_id: str,
remote_room_hosts: List[str],
content: JsonDict,
) -> JsonDict:

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: #8809 (comment)

@anoadragon453 anoadragon453 added Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution z-p3 (Deprecated Label) labels Nov 26, 2020
anoadragon453 added a commit that referenced this issue Nov 27, 2020
This PR grew out of #6739, and adds typing to some method arguments

You'll notice that there are a lot of `# type: ignores` in here. This is due to the base methods not matching the overloads here. This is necessary to stop mypy complaining, but a better solution is #8828.
@MadLittleMods MadLittleMods added the T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks. label Apr 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks. Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution z-p3 (Deprecated Label)
Projects
None yet
Development

No branches or pull requests

2 participants