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

Commit 19e5d44

Browse files
author
David Robertson
committed
Revert "Update locked versions of mypy and mypy-zope (#13521)"
This reverts commit f383b9b. Other PRs were seeing mypy failures that looked to be related to mypy-zope. Confusingly, we didn't see this on #13521. Revert this for now and investigate later.
1 parent 46bd7f4 commit 19e5d44

File tree

7 files changed

+73
-60
lines changed

7 files changed

+73
-60
lines changed

changelog.d/13521.misc

Lines changed: 0 additions & 1 deletion
This file was deleted.

poetry.lock

Lines changed: 39 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

synapse/app/_base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ def register_sighup(func: Callable[P, None], *args: P.args, **kwargs: P.kwargs)
9898
func: Function to be called when sent a SIGHUP signal.
9999
*args, **kwargs: args and kwargs to be passed to the target function.
100100
"""
101-
_sighup_callbacks.append((func, args, kwargs))
101+
# This type-ignore should be redundant once we use a mypy release with
102+
# https://github.com/python/mypy/pull/12668.
103+
_sighup_callbacks.append((func, args, kwargs)) # type: ignore[arg-type]
102104

103105

104106
def start_worker_reactor(

synapse/logging/context.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -586,29 +586,29 @@ def filter(self, record: logging.LogRecord) -> Literal[True]:
586586
True to include the record in the log output.
587587
"""
588588
context = current_context()
589-
record.request = self._default_request
589+
record.request = self._default_request # type: ignore
590590

591591
# context should never be None, but if it somehow ends up being, then
592592
# we end up in a death spiral of infinite loops, so let's check, for
593593
# robustness' sake.
594594
if context is not None:
595595
# Logging is interested in the request ID. Note that for backwards
596596
# compatibility this is stored as the "request" on the record.
597-
record.request = str(context)
597+
record.request = str(context) # type: ignore
598598

599599
# Add some data from the HTTP request.
600600
request = context.request
601601
if request is None:
602602
return True
603603

604-
record.ip_address = request.ip_address
605-
record.site_tag = request.site_tag
606-
record.requester = request.requester
607-
record.authenticated_entity = request.authenticated_entity
608-
record.method = request.method
609-
record.url = request.url
610-
record.protocol = request.protocol
611-
record.user_agent = request.user_agent
604+
record.ip_address = request.ip_address # type: ignore
605+
record.site_tag = request.site_tag # type: ignore
606+
record.requester = request.requester # type: ignore
607+
record.authenticated_entity = request.authenticated_entity # type: ignore
608+
record.method = request.method # type: ignore
609+
record.url = request.url # type: ignore
610+
record.protocol = request.protocol # type: ignore
611+
record.user_agent = request.user_agent # type: ignore
612612

613613
return True
614614

synapse/logging/opentracing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,9 +966,9 @@ def _wrapping_logic(
966966
# FIXME: We could update this to handle any type of function by ignoring the
967967
# first argument only if it's named `self` or `cls`. This isn't fool-proof
968968
# but handles the idiomatic cases.
969-
for i, arg in enumerate(args[1:], start=1):
969+
for i, arg in enumerate(args[1:], start=1): # type: ignore[index]
970970
set_tag("ARG_" + argspec.args[i], str(arg))
971-
set_tag("args", str(args[len(argspec.args) :]))
971+
set_tag("args", str(args[len(argspec.args) :])) # type: ignore[index]
972972
set_tag("kwargs", str(kwargs))
973973
yield
974974

synapse/storage/database.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ def call_after(
288288
# LoggingTransaction isn't expecting there to be any callbacks; assert that
289289
# is not the case.
290290
assert self.after_callbacks is not None
291-
self.after_callbacks.append((callback, args, kwargs))
291+
# type-ignore: need mypy containing https://github.com/python/mypy/pull/12668
292+
self.after_callbacks.append((callback, args, kwargs)) # type: ignore[arg-type]
292293

293294
def async_call_after(
294295
self, callback: Callable[P, Awaitable], *args: P.args, **kwargs: P.kwargs
@@ -309,7 +310,8 @@ def async_call_after(
309310
# LoggingTransaction isn't expecting there to be any callbacks; assert that
310311
# is not the case.
311312
assert self.async_after_callbacks is not None
312-
self.async_after_callbacks.append((callback, args, kwargs))
313+
# type-ignore: need mypy containing https://github.com/python/mypy/pull/12668
314+
self.async_after_callbacks.append((callback, args, kwargs)) # type: ignore[arg-type]
313315

314316
def call_on_exception(
315317
self, callback: Callable[P, object], *args: P.args, **kwargs: P.kwargs
@@ -327,7 +329,8 @@ def call_on_exception(
327329
# LoggingTransaction isn't expecting there to be any callbacks; assert that
328330
# is not the case.
329331
assert self.exception_callbacks is not None
330-
self.exception_callbacks.append((callback, args, kwargs))
332+
# type-ignore: need mypy containing https://github.com/python/mypy/pull/12668
333+
self.exception_callbacks.append((callback, args, kwargs)) # type: ignore[arg-type]
331334

332335
def fetchone(self) -> Optional[Tuple]:
333336
return self.txn.fetchone()
@@ -408,7 +411,10 @@ def _do_execute(
408411
sql = self.database_engine.convert_param_style(sql)
409412
if args:
410413
try:
411-
sql_logger.debug("[SQL values] {%s} %r", self.name, args[0])
414+
# The type-ignore should be redundant once mypy releases a version with
415+
# https://github.com/python/mypy/pull/12668. (`args` might be empty,
416+
# (but we'll catch the index error if so.)
417+
sql_logger.debug("[SQL values] {%s} %r", self.name, args[0]) # type: ignore[index]
412418
except Exception:
413419
# Don't let logging failures stop SQL from working
414420
pass
@@ -640,15 +646,19 @@ def new_transaction(
640646
# For now, we just log an error, and hope that it works on the first attempt.
641647
# TODO: raise an exception.
642648

643-
for i, arg in enumerate(args):
649+
# Type-ignore Mypy doesn't yet consider ParamSpec.args to be iterable; see
650+
# https://github.com/python/mypy/pull/12668
651+
for i, arg in enumerate(args): # type: ignore[arg-type, var-annotated]
644652
if inspect.isgenerator(arg):
645653
logger.error(
646654
"Programming error: generator passed to new_transaction as "
647655
"argument %i to function %s",
648656
i,
649657
func,
650658
)
651-
for name, val in kwargs.items():
659+
# Type-ignore Mypy doesn't yet consider ParamSpec.args to be a mapping; see
660+
# https://github.com/python/mypy/pull/12668
661+
for name, val in kwargs.items(): # type: ignore[attr-defined]
652662
if inspect.isgenerator(val):
653663
logger.error(
654664
"Programming error: generator passed to new_transaction as "

tests/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,9 @@ def looping_call(
271271
*args: P.args,
272272
**kwargs: P.kwargs,
273273
) -> None:
274-
self.loopers.append(Looper(function, interval / 1000.0, self.now, args, kwargs))
274+
# This type-ignore should be redundant once we use a mypy release with
275+
# https://github.com/python/mypy/pull/12668.
276+
self.loopers.append(Looper(function, interval / 1000.0, self.now, args, kwargs)) # type: ignore[arg-type]
275277

276278
def cancel_call_later(self, timer: Timer, ignore_errs: bool = False) -> None:
277279
if timer.expired:

0 commit comments

Comments
 (0)