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

Fixup synapse.api to pass mypy #6733

Merged
merged 2 commits into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/6733.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixup synapse.api to pass mypy.
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ show_error_codes = True
show_traceback = True
mypy_path = stubs

[mypy-pymacaroons.*]
ignore_missing_imports = True

[mypy-zope]
ignore_missing_imports = True

Expand Down
4 changes: 3 additions & 1 deletion synapse/api/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import List

from six import text_type

import jsonschema
Expand Down Expand Up @@ -293,7 +295,7 @@ def check(self, event):
room_id = None
ev_type = "m.presence"
contains_url = False
labels = []
labels = [] # type: List[str]
else:
sender = event.get("sender", None)
if not sender:
Expand Down
7 changes: 5 additions & 2 deletions synapse/api/ratelimiting.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import collections
from collections import OrderedDict
from typing import Any, Optional, Tuple

from synapse.api.errors import LimitExceededError

Expand All @@ -23,7 +24,9 @@ class Ratelimiter(object):
"""

def __init__(self):
self.message_counts = collections.OrderedDict()
self.message_counts = (
OrderedDict()
) # type: OrderedDict[Any, Tuple[float, int, Optional[float]]]

def can_do_action(self, key, time_now_s, rate_hz, burst_count, update=True):
"""Can the entity (e.g. user or IP address) perform the action?
Expand Down
2 changes: 1 addition & 1 deletion synapse/event_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ def get_public_keys(invite_event):
return public_keys


def auth_types_for_event(event) -> Set[Tuple[str]]:
def auth_types_for_event(event) -> Set[Tuple[str, str]]:
"""Given an event, return a list of (EventType, StateKey) that may be
needed to auth the event. The returned list may be a superset of what
would actually be required depending on the full state of the room.
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ env =
MYPYPATH = stubs/
extras = all
commands = mypy \
synapse/api \
synapse/config/ \
synapse/handlers/ui_auth \
synapse/logging/ \
Expand Down