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

Commit 38f23ef

Browse files
author
David Robertson
committed
Remove unused ignores due to mypy ParamSpec fixes
python/mypy#12668 Cherry-picked from #13521
1 parent 94d80fb commit 38f23ef

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
@@ -992,9 +992,9 @@ def _wrapping_logic(
992992
# FIXME: We could update this to handle any type of function by ignoring the
993993
# first argument only if it's named `self` or `cls`. This isn't fool-proof
994994
# but handles the idiomatic cases.
995-
for i, arg in enumerate(args[1:], start=1): # type: ignore[index]
995+
for i, arg in enumerate(args[1:], start=1):
996996
set_tag(SynapseTags.FUNC_ARG_PREFIX + argspec.args[i], str(arg))
997-
set_tag(SynapseTags.FUNC_ARGS, str(args[len(argspec.args) :])) # type: ignore[index]
997+
set_tag(SynapseTags.FUNC_ARGS, str(args[len(argspec.args) :]))
998998
set_tag(SynapseTags.FUNC_KWARGS, str(kwargs))
999999
yield
10001000

synapse/storage/database.py

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

296295
def async_call_after(
297296
self, callback: Callable[P, Awaitable], *args: P.args, **kwargs: P.kwargs
@@ -312,8 +311,7 @@ def async_call_after(
312311
# LoggingTransaction isn't expecting there to be any callbacks; assert that
313312
# is not the case.
314313
assert self.async_after_callbacks is not None
315-
# type-ignore: need mypy containing https://github.com/python/mypy/pull/12668
316-
self.async_after_callbacks.append((callback, args, kwargs)) # type: ignore[arg-type]
314+
self.async_after_callbacks.append((callback, args, kwargs))
317315

318316
def call_on_exception(
319317
self, callback: Callable[P, object], *args: P.args, **kwargs: P.kwargs
@@ -331,8 +329,7 @@ def call_on_exception(
331329
# LoggingTransaction isn't expecting there to be any callbacks; assert that
332330
# is not the case.
333331
assert self.exception_callbacks is not None
334-
# type-ignore: need mypy containing https://github.com/python/mypy/pull/12668
335-
self.exception_callbacks.append((callback, args, kwargs)) # type: ignore[arg-type]
332+
self.exception_callbacks.append((callback, args, kwargs))
336333

337334
def fetchone(self) -> Optional[Tuple]:
338335
return self.txn.fetchone()
@@ -421,10 +418,7 @@ def _do_execute(
421418
sql = self.database_engine.convert_param_style(sql)
422419
if args:
423420
try:
424-
# The type-ignore should be redundant once mypy releases a version with
425-
# https://github.com/python/mypy/pull/12668. (`args` might be empty,
426-
# (but we'll catch the index error if so.)
427-
sql_logger.debug("[SQL values] {%s} %r", self.name, args[0]) # type: ignore[index]
421+
sql_logger.debug("[SQL values] {%s} %r", self.name, args[0])
428422
except Exception:
429423
# Don't let logging failures stop SQL from working
430424
pass
@@ -655,19 +649,15 @@ def new_transaction(
655649
# For now, we just log an error, and hope that it works on the first attempt.
656650
# TODO: raise an exception.
657651

658-
# Type-ignore Mypy doesn't yet consider ParamSpec.args to be iterable; see
659-
# https://github.com/python/mypy/pull/12668
660-
for i, arg in enumerate(args): # type: ignore[arg-type, var-annotated]
652+
for i, arg in enumerate(args):
661653
if inspect.isgenerator(arg):
662654
logger.error(
663655
"Programming error: generator passed to new_transaction as "
664656
"argument %i to function %s",
665657
i,
666658
func,
667659
)
668-
# Type-ignore Mypy doesn't yet consider ParamSpec.args to be a mapping; see
669-
# https://github.com/python/mypy/pull/12668
670-
for name, val in kwargs.items(): # type: ignore[attr-defined]
660+
for name, val in kwargs.items():
671661
if inspect.isgenerator(val):
672662
logger.error(
673663
"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
@@ -270,9 +270,7 @@ def looping_call(
270270
*args: P.args,
271271
**kwargs: P.kwargs,
272272
) -> None:
273-
# This type-ignore should be redundant once we use a mypy release with
274-
# https://github.com/python/mypy/pull/12668.
275-
self.loopers.append(Looper(function, interval / 1000.0, self.now, args, kwargs)) # type: ignore[arg-type]
273+
self.loopers.append(Looper(function, interval / 1000.0, self.now, args, kwargs))
276274

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

0 commit comments

Comments
 (0)