element-hq / element-hq/synapse

Type information incorrect when @cached methods are passed as parameters

Open
#16,606 0 comments 0 reactions 0 assignees View on GitHub
O-Uncommon S-Minor T-Defect
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

This issue has been migrated from [#16606](https://github.com/matrix-org/synapse/issues/16606).

---

If a method that is wrapped in `@cached` is passed into another function, e.g. `run_in_background` then the type information is incorrect; the current mypy plugin only updates the type information when it is called as a method, not when it is accessed as an attribute.

E.g. from #16590:

```
synapse/push/bulk_push_rule_evaluator.py:359: error: Missing positional argument "room_id" in call to "run_in_background" [call-arg]
synapse/push/bulk_push_rule_evaluator.py:360: error: Argument 2 to "run_in_background" has incompatible type "str"; expected "RoomMemberWorkerStore" [arg-type]
```

The method is not getting treated as bound (and there might be other issues too).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.