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

Commit

Permalink
Add some tiny type annotations (#7870)
Browse files Browse the repository at this point in the history
I found these made pycharm have more of a clue as to what was going on in other places.
  • Loading branch information
richvdh authored Jul 16, 2020
1 parent 12528dc commit a973bcb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog.d/7870.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add some type annotations to `HomeServer` and `BaseHandler`.
10 changes: 4 additions & 6 deletions synapse/handlers/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

from twisted.internet import defer

import synapse.state
import synapse.storage
import synapse.types
from synapse.api.constants import EventTypes, Membership
from synapse.api.ratelimiting import Ratelimiter
Expand All @@ -28,21 +30,17 @@
class BaseHandler(object):
"""
Common base class for the event handlers.
Attributes:
store (synapse.storage.DataStore):
state_handler (synapse.state.StateHandler):
"""

def __init__(self, hs):
"""
Args:
hs (synapse.server.HomeServer):
"""
self.store = hs.get_datastore()
self.store = hs.get_datastore() # type: synapse.storage.DataStore
self.auth = hs.get_auth()
self.notifier = hs.get_notifier()
self.state_handler = hs.get_state_handler()
self.state_handler = hs.get_state_handler() # type: synapse.state.StateHandler
self.distributor = hs.get_distributor()
self.clock = hs.get_clock()
self.hs = hs
Expand Down
4 changes: 2 additions & 2 deletions synapse/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
WorkerServerNoticesSender,
)
from synapse.state import StateHandler, StateResolutionHandler
from synapse.storage import DataStores, Storage
from synapse.storage import DataStore, DataStores, Storage
from synapse.streams.events import EventSources
from synapse.util import Clock
from synapse.util.distributor import Distributor
Expand Down Expand Up @@ -312,7 +312,7 @@ def is_mine_id(self, string):
def get_clock(self):
return self.clock

def get_datastore(self):
def get_datastore(self) -> DataStore:
return self.datastores.main

def get_datastores(self):
Expand Down

0 comments on commit a973bcb

Please sign in to comment.