-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add type hints to the spam check module #6915
Conversation
d5a3e9d
to
e998c3c
Compare
e998c3c
to
3252160
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! A couple of points for future ref below.
self.hs = hs | ||
|
||
self._store = hs.get_datastore() | ||
|
||
@defer.inlineCallbacks | ||
def get_state_events_in_room(self, room_id, types): | ||
def get_state_events_in_room(self, room_id: str, types: tuple) -> defer.Deferred: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally we've been declaring bankruptcy when trying to declare the return type of @defer.inlineCalbacks
functions; the problem being that it's only the decorated version of the function that actually returns a Deferred and mypy etc get confused when you try to return state.values()
instead.
Instead we either convert to async/await
first, or just leave the return type unannotated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. I can just remove the return type for now if that matches what is done in other places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't matter. I'd just land it.
* commit '10027c80b': Add type hints to the spam check module (#6915)
This adds type hints to the spam check module and has mypy check it.
This is my first foray into typing so hopefully I didn't do anything crazy.
I spun this out of #6906 since I couldn't get it working, but I've since fixed the issue.