An attempt to type tests.util.caches#15032
Conversation
I think sticking some |
| # type-ignore: mypy thinks the RHS is None; we need to fix the annotation for | ||
| # @cached here. |
There was a problem hiding this comment.
This sounds like the mypy plugin for cached isn't working at all then? This makes me very nervous to ignore TBH.
There was a problem hiding this comment.
I think it works okay in Synapse proper, when @cached decorates an async def and is awaited. I don't think it works well if you're trying to get at the underlying Deferred machinery, as we are here.
There was a problem hiding this comment.
Does it Just Work™️ if we use async def instead?
|
Haven't got the time to look at this right now. Going to close it for now since we weren't very happy with how the mypy plugin handles |
This wasn't very satisfactory: I had to resort to a lot of type-ignores here.
I struggle to understand our caching descriptor machinery at the best of times, but I think that the annotations for
@cached, plus whatever we do in the Synapse mypy plugin isn't quite working right in these tests.It's not chopped up into meaningful commits; I am happy to rebase this to do so if it would be helpful.
LMK what you think. Is this good enough to land, or should we look for a different approach?