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

Commit 2f3415b

Browse files
author
David Robertson
committed
Remove unused ignores due to mypy ParamSpec fixes
python/mypy#12668
1 parent b0530bf commit 2f3415b

File tree

4 files changed

+10
-24
lines changed

4 files changed

+10
-24
lines changed

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/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)