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

Commit c911efd

Browse files
committed
Enable type hints for servlet file.
1 parent 2473305 commit c911efd

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

mypy.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ files =
3232
synapse/http/federation/matrix_federation_agent.py,
3333
synapse/http/federation/well_known_resolver.py,
3434
synapse/http/matrixfederationclient.py,
35+
synapse/http/servlet.py,
3536
synapse/http/server.py,
3637
synapse/http/site.py,
3738
synapse/logging,

synapse/http/servlet.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ def parse_string(
197197
parameter is present, must be one of a list of allowed values and
198198
is not one of those allowed values.
199199
"""
200+
args = request.args # type: Dict[bytes, List[bytes]] # type: ignore
200201
return parse_string_from_args(
201-
request.args, name, default, required, allowed_values, encoding
202+
args, name, default, required, allowed_values, encoding
202203
)
203204

204205

@@ -422,9 +423,8 @@ class attribute containing a pre-compiled regular expression. The automatic
422423

423424
def register(self, http_server):
424425
""" Register this servlet with the given HTTP server. """
425-
if hasattr(self, "PATTERNS"):
426-
patterns = self.PATTERNS
427-
426+
patterns = getattr(self, "PATTERNS", None)
427+
if patterns:
428428
for method in ("GET", "PUT", "POST", "DELETE"):
429429
if hasattr(self, "on_%s" % (method,)):
430430
servlet_classname = self.__class__.__name__

0 commit comments

Comments
 (0)