summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-12-13 11:32:53 +0000
committerGitHub <noreply@github.com>2019-12-13 11:32:53 +0000
commit5cadbd9ebb6cc9e6e2e15ab3f77fcbca47d53392 (patch)
tree811fec2b55d1566cc294de5747842d615932b8d4
parentMerge branch 'master' into develop (diff)
parentNewsfile (diff)
downloadsynapse-5cadbd9ebb6cc9e6e2e15ab3f77fcbca47d53392.tar.xz
Merge pull request #6537 from matrix-org/erikj/bump_mypy_version
Bump mypy version
-rw-r--r--changelog.d/6537.misc1
-rw-r--r--synapse/config/emailconfig.py3
-rw-r--r--synapse/config/ratelimiting.py3
-rw-r--r--synapse/config/server.py2
-rw-r--r--synapse/logging/_terse_json.py2
-rw-r--r--synapse/logging/context.py3
-rw-r--r--synapse/streams/events.py4
-rw-r--r--tox.ini2
8 files changed, 13 insertions, 7 deletions
diff --git a/changelog.d/6537.misc b/changelog.d/6537.misc
new file mode 100644
index 0000000000..3543153584
--- /dev/null
+++ b/changelog.d/6537.misc
@@ -0,0 +1 @@
+Update `mypy` to new version.
diff --git a/synapse/config/emailconfig.py b/synapse/config/emailconfig.py
index 18f42a87f9..35756bed87 100644
--- a/synapse/config/emailconfig.py
+++ b/synapse/config/emailconfig.py
@@ -21,6 +21,7 @@ from __future__ import print_function
 import email.utils
 import os
 from enum import Enum
+from typing import Optional
 
 import pkg_resources
 
@@ -101,7 +102,7 @@ class EmailConfig(Config):
                 # both in RegistrationConfig and here. We should factor this bit out
                 self.account_threepid_delegate_email = self.trusted_third_party_id_servers[
                     0
-                ]
+                ]  # type: Optional[str]
                 self.using_identity_server_from_trusted_list = True
             else:
                 raise ConfigError(
diff --git a/synapse/config/ratelimiting.py b/synapse/config/ratelimiting.py
index 947f653e03..4a3bfc4354 100644
--- a/synapse/config/ratelimiting.py
+++ b/synapse/config/ratelimiting.py
@@ -83,10 +83,9 @@ class RatelimitConfig(Config):
         )
 
         rc_admin_redaction = config.get("rc_admin_redaction")
+        self.rc_admin_redaction = None
         if rc_admin_redaction:
             self.rc_admin_redaction = RateLimitConfig(rc_admin_redaction)
-        else:
-            self.rc_admin_redaction = None
 
     def generate_config_section(self, **kwargs):
         return """\
diff --git a/synapse/config/server.py b/synapse/config/server.py
index a4bef00936..50af858c76 100644
--- a/synapse/config/server.py
+++ b/synapse/config/server.py
@@ -200,7 +200,7 @@ class ServerConfig(Config):
         self.admin_contact = config.get("admin_contact", None)
 
         # FIXME: federation_domain_whitelist needs sytests
-        self.federation_domain_whitelist = None
+        self.federation_domain_whitelist = None  # type: Optional[dict]
         federation_domain_whitelist = config.get("federation_domain_whitelist", None)
 
         if federation_domain_whitelist is not None:
diff --git a/synapse/logging/_terse_json.py b/synapse/logging/_terse_json.py
index 03934956f4..c0b9384189 100644
--- a/synapse/logging/_terse_json.py
+++ b/synapse/logging/_terse_json.py
@@ -171,7 +171,7 @@ class LogProducer(object):
 
     def stopProducing(self):
         self._paused = True
-        self._buffer = None
+        self._buffer = deque()
 
     def resumeProducing(self):
         self._paused = False
diff --git a/synapse/logging/context.py b/synapse/logging/context.py
index 6747f29e6a..33b322209d 100644
--- a/synapse/logging/context.py
+++ b/synapse/logging/context.py
@@ -405,6 +405,9 @@ class LoggingContext(object):
         """
         current = get_thread_resource_usage()
 
+        # Indicate to mypy that we know that self.usage_start is None.
+        assert self.usage_start is not None
+
         utime_delta = current.ru_utime - self.usage_start.ru_utime
         stime_delta = current.ru_stime - self.usage_start.ru_stime
 
diff --git a/synapse/streams/events.py b/synapse/streams/events.py
index b91fb2db7b..fcd2aaa9c9 100644
--- a/synapse/streams/events.py
+++ b/synapse/streams/events.py
@@ -13,6 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from typing import Any, Dict
+
 from twisted.internet import defer
 
 from synapse.handlers.account_data import AccountDataEventSource
@@ -35,7 +37,7 @@ class EventSources(object):
     def __init__(self, hs):
         self.sources = {
             name: cls(hs) for name, cls in EventSources.SOURCE_TYPES.items()
-        }
+        }  # type: Dict[str, Any]
         self.store = hs.get_datastore()
 
     @defer.inlineCallbacks
diff --git a/tox.ini b/tox.ini
index 2ae82d674f..1d6428f64f 100644
--- a/tox.ini
+++ b/tox.ini
@@ -171,7 +171,7 @@ basepython = python3.7
 skip_install = True
 deps =
     {[base]deps}
-    mypy==0.730
+    mypy==0.750
     mypy-zope
 env =
     MYPYPATH = stubs/