Skip to content

Commit aae6757

Browse files
committed
Silence pyright errors without changing existing code
1 parent 106efcd commit aae6757

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

toolz/functoolz.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def __init__(self, *args, **kwargs):
222222

223223
self.__doc__ = getattr(func, '__doc__', None)
224224
self.__name__ = getattr(func, '__name__', '<curry>')
225-
self.__module__ = getattr(func, '__module__', None)
225+
self.__module__ = getattr(func, '__module__', None) # pyright: ignore
226226
self.__qualname__ = getattr(func, '__qualname__', None)
227227
self._sigspec = None
228228
self._has_unknown_args = None
@@ -241,7 +241,7 @@ def __signature__(self):
241241

242242
params = list(sig.parameters.values())
243243
skip = 0
244-
for param in params[:len(args)]:
244+
for param in params[:len(args)]: # pyright: ignore
245245
if param.kind == param.VAR_POSITIONAL:
246246
break
247247
skip += 1
@@ -256,8 +256,8 @@ def __signature__(self):
256256
elif kind == param.VAR_POSITIONAL:
257257
if kwonly:
258258
continue
259-
elif param.name in keywords:
260-
default = keywords[param.name]
259+
elif param.name in keywords: # pyright: ignore
260+
default = keywords[param.name] # pyright: ignore
261261
kind = param.KEYWORD_ONLY
262262
kwonly = True
263263
else:
@@ -311,7 +311,7 @@ def _should_curry(self, args, kwargs, exc=None):
311311
func = self.func
312312
args = self.args + args
313313
if self.keywords:
314-
kwargs = dict(self.keywords, **kwargs)
314+
kwargs = dict(self.keywords, **kwargs) # pyright: ignore
315315
if self._sigspec is None:
316316
sigspec = self._sigspec = _sigs.signature_or_spec(func)
317317
self._has_unknown_args = has_varargs(func, sigspec) is not False
@@ -390,7 +390,7 @@ def _restore_curry(cls, func, args, kwargs, userdict, is_decorated):
390390

391391

392392
@curry
393-
def memoize(func, cache=None, key=None):
393+
def memoize(func, cache=None, key=None): # pyright: ignore
394394
""" Cache a function's result for speedy future evaluation
395395
396396
Considerations:
@@ -442,7 +442,7 @@ def memoize(func, cache=None, key=None):
442442
def key(args, kwargs):
443443
return args[0]
444444
elif may_have_kwargs:
445-
def key(args, kwargs):
445+
def key(args, kwargs): # pyright: ignore
446446
return (
447447
args or None,
448448
frozenset(kwargs.items()) if kwargs else None,
@@ -495,7 +495,7 @@ def __getstate__(self):
495495
def __setstate__(self, state):
496496
self.first, self.funcs = state
497497

498-
@instanceproperty(classval=__doc__)
498+
@instanceproperty(classval=__doc__) # pyright: ignore
499499
def __doc__(self):
500500
def composed_doc(*fs):
501501
"""Generate a docstring for the composition of fs.
@@ -776,7 +776,7 @@ def __call__(self, *args, **kwargs):
776776
except self.exc as e:
777777
return self.handler(e)
778778

779-
@instanceproperty(classval=__doc__)
779+
@instanceproperty(classval=__doc__) # pyright: ignore
780780
def __doc__(self):
781781
from textwrap import dedent
782782

toolz/itertoolz.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def interleave(seqs):
241241
yield next(itr)
242242
return
243243
except StopIteration:
244-
predicate = partial(operator.is_not, itr)
244+
predicate = partial(operator.is_not, itr) # pyright: ignore
245245
iters = itertools.cycle(itertools.takewhile(predicate, iters))
246246

247247

@@ -625,7 +625,7 @@ def reduceby(key, binop, seq, init=no_default):
625625
d[k] = item
626626
continue
627627
else:
628-
d[k] = init()
628+
d[k] = init() # pyright: ignore
629629
d[k] = binop(d[k], item)
630630
return d
631631

@@ -1054,4 +1054,7 @@ def random_sample(prob, seq, random_state=None):
10541054
from random import Random
10551055

10561056
random_state = Random(random_state)
1057-
return filter(lambda _: random_state.random() < prob, seq)
1057+
return filter(
1058+
lambda _: random_state.random() < prob, # pyright: ignore
1059+
seq,
1060+
)

toolz/sandbox/core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __hash__(self):
7474
if self.key == self._default_hashkey:
7575
val = self.key
7676
else:
77-
val = self.key(self.item)
77+
val = self.key(self.item) # pyright: ignore
7878
return hash(val)
7979

8080
def __eq__(self, other):

0 commit comments

Comments
 (0)