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

Commit f383b9b

Browse files
author
David Robertson
authored
Update locked versions of mypy and mypy-zope (#13521)
1 parent 434fd82 commit f383b9b

File tree

7 files changed

+60
-73
lines changed

7 files changed

+60
-73
lines changed

changelog.d/13521.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update locked versions of mypy and mypy-zope.

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: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ 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-
# 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]
101+
_sighup_callbacks.append((func, args, kwargs))
104102

105103

106104
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 # type: ignore
589+
record.request = self._default_request
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) # type: ignore
597+
record.request = str(context)
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 # 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
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
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): # type: ignore[index]
969+
for i, arg in enumerate(args[1:], start=1):
970970
set_tag("ARG_" + argspec.args[i], str(arg))
971-
set_tag("args", str(args[len(argspec.args) :])) # type: ignore[index]
971+
set_tag("args", str(args[len(argspec.args) :]))
972972
set_tag("kwargs", str(kwargs))
973973
yield
974974

synapse/storage/database.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,7 @@ 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-
# type-ignore: need mypy containing https://github.com/python/mypy/pull/12668
292-
self.after_callbacks.append((callback, args, kwargs)) # type: ignore[arg-type]
291+
self.after_callbacks.append((callback, args, kwargs))
293292

294293
def async_call_after(
295294
self, callback: Callable[P, Awaitable], *args: P.args, **kwargs: P.kwargs
@@ -310,8 +309,7 @@ def async_call_after(
310309
# LoggingTransaction isn't expecting there to be any callbacks; assert that
311310
# is not the case.
312311
assert self.async_after_callbacks is not None
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]
312+
self.async_after_callbacks.append((callback, args, kwargs))
315313

316314
def call_on_exception(
317315
self, callback: Callable[P, object], *args: P.args, **kwargs: P.kwargs
@@ -329,8 +327,7 @@ def call_on_exception(
329327
# LoggingTransaction isn't expecting there to be any callbacks; assert that
330328
# is not the case.
331329
assert self.exception_callbacks is not None
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]
330+
self.exception_callbacks.append((callback, args, kwargs))
334331

335332
def fetchone(self) -> Optional[Tuple]:
336333
return self.txn.fetchone()
@@ -411,10 +408,7 @@ def _do_execute(
411408
sql = self.database_engine.convert_param_style(sql)
412409
if args:
413410
try:
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]
411+
sql_logger.debug("[SQL values] {%s} %r", self.name, args[0])
418412
except Exception:
419413
# Don't let logging failures stop SQL from working
420414
pass
@@ -646,19 +640,15 @@ def new_transaction(
646640
# For now, we just log an error, and hope that it works on the first attempt.
647641
# TODO: raise an exception.
648642

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]
643+
for i, arg in enumerate(args):
652644
if inspect.isgenerator(arg):
653645
logger.error(
654646
"Programming error: generator passed to new_transaction as "
655647
"argument %i to function %s",
656648
i,
657649
func,
658650
)
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]
651+
for name, val in kwargs.items():
662652
if inspect.isgenerator(val):
663653
logger.error(
664654
"Programming error: generator passed to new_transaction as "

tests/utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,7 @@ def looping_call(
271271
*args: P.args,
272272
**kwargs: P.kwargs,
273273
) -> None:
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]
274+
self.loopers.append(Looper(function, interval / 1000.0, self.now, args, kwargs))
277275

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

0 commit comments

Comments
 (0)