summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
Diffstat (limited to 'synapse')
-rw-r--r--synapse/handlers/auth.py4
-rw-r--r--synapse/handlers/sso.py2
-rw-r--r--synapse/logging/context.py6
-rw-r--r--synapse/module_api/callbacks/spamchecker_callbacks.py2
-rw-r--r--synapse/storage/database.py6
-rw-r--r--synapse/storage/databases/main/events_worker.py4
-rw-r--r--synapse/streams/events.py9
-rw-r--r--synapse/util/async_helpers.py12
-rw-r--r--synapse/util/caches/dictionary_cache.py2
-rw-r--r--synapse/util/caches/expiringcache.py2
10 files changed, 19 insertions, 30 deletions
diff --git a/synapse/handlers/auth.py b/synapse/handlers/auth.py
index f233f1b034..a1fab99f6b 100644
--- a/synapse/handlers/auth.py
+++ b/synapse/handlers/auth.py
@@ -2185,7 +2185,7 @@ class PasswordAuthProvider:
                 # result is always the right type, but as it is 3rd party code it might not be
 
                 if not isinstance(result, tuple) or len(result) != 2:
-                    logger.warning(
+                    logger.warning(  # type: ignore[unreachable]
                         "Wrong type returned by module API callback %s: %s, expected"
                         " Optional[Tuple[str, Optional[Callable]]]",
                         callback,
@@ -2248,7 +2248,7 @@ class PasswordAuthProvider:
                 # result is always the right type, but as it is 3rd party code it might not be
 
                 if not isinstance(result, tuple) or len(result) != 2:
-                    logger.warning(
+                    logger.warning(  # type: ignore[unreachable]
                         "Wrong type returned by module API callback %s: %s, expected"
                         " Optional[Tuple[str, Optional[Callable]]]",
                         callback,
diff --git a/synapse/handlers/sso.py b/synapse/handlers/sso.py
index 437cb5509c..8e39e76c97 100644
--- a/synapse/handlers/sso.py
+++ b/synapse/handlers/sso.py
@@ -150,7 +150,7 @@ class UserAttributes:
     display_name: Optional[str] = None
     picture: Optional[str] = None
     # mypy thinks these are incompatible for some reason.
-    emails: StrCollection = attr.Factory(list)  # type: ignore[assignment]
+    emails: StrCollection = attr.Factory(list)
 
 
 @attr.s(slots=True, auto_attribs=True)
diff --git a/synapse/logging/context.py b/synapse/logging/context.py
index b36f397574..4650b60962 100644
--- a/synapse/logging/context.py
+++ b/synapse/logging/context.py
@@ -776,11 +776,7 @@ def run_in_background(
 ) -> "defer.Deferred[R]": ...
 
 
-def run_in_background(  # type: ignore[misc]
-    # The `type: ignore[misc]` above suppresses
-    # "Overloaded function implementation does not accept all possible arguments of signature 1"
-    # "Overloaded function implementation does not accept all possible arguments of signature 2"
-    # which seems like a bug in mypy.
+def run_in_background(
     f: Union[
         Callable[P, R],
         Callable[P, Awaitable[R]],
diff --git a/synapse/module_api/callbacks/spamchecker_callbacks.py b/synapse/module_api/callbacks/spamchecker_callbacks.py
index 6ec56a7f14..17079ff781 100644
--- a/synapse/module_api/callbacks/spamchecker_callbacks.py
+++ b/synapse/module_api/callbacks/spamchecker_callbacks.py
@@ -455,7 +455,7 @@ class SpamCheckerModuleApiCallbacks:
                     # mypy complains that we can't reach this code because of the
                     # return type in CHECK_EVENT_FOR_SPAM_CALLBACK, but we don't know
                     # for sure that the module actually returns it.
-                    logger.warning(
+                    logger.warning(  # type: ignore[unreachable]
                         "Module returned invalid value, rejecting message as spam"
                     )
                     res = "This message has been rejected as probable spam"
diff --git a/synapse/storage/database.py b/synapse/storage/database.py
index d7d202f028..d9c85e411e 100644
--- a/synapse/storage/database.py
+++ b/synapse/storage/database.py
@@ -913,9 +913,9 @@ class DatabasePool:
 
             try:
                 with opentracing.start_active_span(f"db.{desc}"):
-                    result = await self.runWithConnection(
+                    result: R = await self.runWithConnection(
                         # mypy seems to have an issue with this, maybe a bug?
-                        self.new_transaction,  # type: ignore[arg-type]
+                        self.new_transaction,
                         desc,
                         after_callbacks,
                         async_after_callbacks,
@@ -934,7 +934,7 @@ class DatabasePool:
                     await async_callback(*async_args, **async_kwargs)
                 for after_callback, after_args, after_kwargs in after_callbacks:
                     after_callback(*after_args, **after_kwargs)
-                return cast(R, result)
+                return result
             except Exception:
                 for exception_callback, after_args, after_kwargs in exception_callbacks:
                     exception_callback(*after_args, **after_kwargs)
diff --git a/synapse/storage/databases/main/events_worker.py b/synapse/storage/databases/main/events_worker.py
index 4c09567a7a..81fccfbccb 100644
--- a/synapse/storage/databases/main/events_worker.py
+++ b/synapse/storage/databases/main/events_worker.py
@@ -1876,7 +1876,7 @@ class EventsWorkerStore(SQLBaseStore):
             # Type safety: iterating over `txn` yields `Tuple`, i.e.
             # `Tuple[Any, ...]` of arbitrary length. Mypy detects assigning a
             # variadic tuple to a fixed length tuple and flags it up as an error.
-            for row in txn:  # type: ignore[assignment]
+            for row in txn:
                 new_event_updates.append((row[0], row[1:]))
 
             limited = False
@@ -1903,7 +1903,7 @@ class EventsWorkerStore(SQLBaseStore):
             # Type safety: iterating over `txn` yields `Tuple`, i.e.
             # `Tuple[Any, ...]` of arbitrary length. Mypy detects assigning a
             # variadic tuple to a fixed length tuple and flags it up as an error.
-            for row in txn:  # type: ignore[assignment]
+            for row in txn:
                 new_event_updates.append((row[0], row[1:]))
 
             if len(new_event_updates) >= limit:
diff --git a/synapse/streams/events.py b/synapse/streams/events.py
index 7466488157..dd7401ac8e 100644
--- a/synapse/streams/events.py
+++ b/synapse/streams/events.py
@@ -57,12 +57,13 @@ class _EventSourcesInner:
 class EventSources:
     def __init__(self, hs: "HomeServer"):
         self.sources = _EventSourcesInner(
-            # mypy previously warned that attribute.type is `Optional`, but we know it's
+            # attribute.type is `Optional`, but we know it's
             # never `None` here since all the attributes of `_EventSourcesInner` are
             # annotated.
-            # As of the stubs in attrs 22.1.0, `attr.fields()` now returns Any,
-            # so the call to `attribute.type` is not checked.
-            *(attribute.type(hs) for attribute in attr.fields(_EventSourcesInner))
+            *(
+                attribute.type(hs)  # type: ignore[misc]
+                for attribute in attr.fields(_EventSourcesInner)
+            )
         )
         self.store = hs.get_datastores().main
         self._instance_name = hs.get_instance_name()
diff --git a/synapse/util/async_helpers.py b/synapse/util/async_helpers.py
index d50b5dd346..70139beef2 100644
--- a/synapse/util/async_helpers.py
+++ b/synapse/util/async_helpers.py
@@ -284,15 +284,7 @@ async def yieldable_gather_results(
     try:
         return await make_deferred_yieldable(
             defer.gatherResults(
-                # type-ignore: mypy reports two errors:
-                # error: Argument 1 to "run_in_background" has incompatible type
-                #     "Callable[[T, **P], Awaitable[R]]"; expected
-                #     "Callable[[T, **P], Awaitable[R]]"  [arg-type]
-                # error: Argument 2 to "run_in_background" has incompatible type
-                #     "T"; expected "[T, **P.args]"  [arg-type]
-                # The former looks like a mypy bug, and the latter looks like a
-                # false positive.
-                [run_in_background(func, item, *args, **kwargs) for item in iter],  # type: ignore[arg-type]
+                [run_in_background(func, item, *args, **kwargs) for item in iter],
                 consumeErrors=True,
             )
         )
@@ -338,7 +330,7 @@ async def yieldable_gather_results_delaying_cancellation(
         return await make_deferred_yieldable(
             delay_cancellation(
                 defer.gatherResults(
-                    [run_in_background(func, item, *args, **kwargs) for item in iter],  # type: ignore[arg-type]
+                    [run_in_background(func, item, *args, **kwargs) for item in iter],
                     consumeErrors=True,
                 )
             )
diff --git a/synapse/util/caches/dictionary_cache.py b/synapse/util/caches/dictionary_cache.py
index 4245b7289c..1e6696332f 100644
--- a/synapse/util/caches/dictionary_cache.py
+++ b/synapse/util/caches/dictionary_cache.py
@@ -229,7 +229,7 @@ class DictionaryCache(Generic[KT, DKT, DV]):
         for dict_key in missing:
             # We explicitly add each dict key to the cache, so that cache hit
             # rates and LRU times for each key can be tracked separately.
-            value = entry.get(dict_key, _Sentinel.sentinel)  # type: ignore[arg-type]
+            value = entry.get(dict_key, _Sentinel.sentinel)
             self.cache[(key, dict_key)] = _PerKeyValue(value)
 
             if value is not _Sentinel.sentinel:
diff --git a/synapse/util/caches/expiringcache.py b/synapse/util/caches/expiringcache.py
index 462016f820..8017c031ee 100644
--- a/synapse/util/caches/expiringcache.py
+++ b/synapse/util/caches/expiringcache.py
@@ -142,7 +142,7 @@ class ExpiringCache(Generic[KT, VT]):
             return default
 
         if self.iterable:
-            self.metrics.inc_evictions(EvictionReason.invalidation, len(value.value))  # type: ignore[arg-type]
+            self.metrics.inc_evictions(EvictionReason.invalidation, len(value.value))
         else:
             self.metrics.inc_evictions(EvictionReason.invalidation)