8000 Make some type: ignore comments more specific · domdfcoding/domdf_python_tools@2f77691 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f77691

Browse files
committed
Make some type: ignore comments more specific
1 parent fbcd9fa commit 2f77691

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

domdf_python_tools/bases.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def __getstate__(self) -> Dict[str, _V]:
106106
return self.__dict__
107107

108108
def __setstate__(self, state):
109-
self.__init__(**state) # type: ignore
109+
self.__init__(**state) # type: ignore[misc]
110110

111111
def __copy__(self):
112112
return self.__class__(**self.__dict__)
@@ -219,7 +219,7 @@ def __setitem__(self, i: int, o: _T) -> None: ...
219219
def __setitem__(self, i: slice, o: Iterable[_T]) -> None: ...
220220

221221
def __setitem__(self, i: Union[int, slice], item: Union[_T, Iterable[_T]]) -> None:
222-
self.data[i] = item # type: ignore
222+
self.data[i] = item # type: ignore[index, assignment]
223223

224224
def __delitem__(self, i: Union[int, slice]):
225225
del self.data[i]
@@ -422,7 +422,7 @@ def __sub__(self: _F, other: float) -> _F:
422422
def __mul__(self: _F, other: float) -> _F:
423423
return self.__class__(float(self).__mul__(other))
424424

425-
def __floordiv__(self: _F, other: float) -> _F: # type: ignore
425+
def __floordiv__(self: _F, other: float) -> _F: # type: ignore[override]
426426
return self.__class__(float(self).__floordiv__(other))
427427

428428
def __truediv__(self: _F, other: float) -> _F:
@@ -432,7 +432,7 @@ def __mod__(self: _F, other: float) -> _F:
432432
return self.__class__(float(self).__mod__(other))
433433

434434
def __divmod__(self: _F, other: float) -> Tuple[_F, _F]:
435-
return tuple(self.__class__(x) for x in float(self).__divmod__(other)) # type: ignore
435+
return tuple(self.__class__(x) for x in float(self).__divmod__(other)) # type: ignore[return-value]
436436

437437
def __pow__(self: _F, other: float, mod=None) -> _F:
438438
return self.__class__(float(self).__pow__(other, mod))
@@ -446,7 +446,7 @@ def __rsub__(self: _F, other: float) -> _F:
446446
def __rmul__(self: _F, other: float) -> _F:
447447
return self.__class__(float(self).__rmul__(other))
448448

449-
def __rfloordiv__(self: _F, other: float) -> _F: # type: ignore
449+
def __rfloordiv__(self: _F, other: float) -> _F: # type: ignore[override]
450450
return self.__class__(float(self).__rfloordiv__(other))
451451

452452
def __rtruediv__(self: _F, other: float) -> _F:

tests/test_getters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ class A:
5555
f([a, b])
5656

5757
with pytest.raises(TypeError, match="attribute name must be a string"):
58-
attrgetter(0, 2) # type: ignore
58+
attrgetter(0, 2) # type: ignore[arg-type]
5959

6060
with pytest.raises(TypeError, match="'idx' must be an integer"):
61-
attrgetter("hello", 0) # type: ignore
61+
attrgetter("hello", 0) # type: ignore[arg-type]
6262

6363
with pytest.raises(TypeError, match=r"__init__\(\) missing 1 required positional argument: 'attr'"):
64-
attrgetter(0) # type: ignore
64+
attrgetter(0) # type: ignore[call-arg]
6565

6666
f = attrgetter(1, "name")
6767

tests/test_iterativ 8000 e.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,10 @@ def test_count():
313313
assert take(2, zip("abc", count(-3))) == [('a', -3), ('b', -2)]
314314

315315
with pytest.raises(TypeError, match=r"count\(\) takes from 0 to 2 positional arguments but 3 were given"):
316-
count(2, 3, 4) # type: ignore
316+
count(2, 3, 4) # type: ignore[call-arg]
317317

318318
with pytest.raises(TypeError, match="a number is required"):
319-
count('a') # type: ignore
319+
count('a') # type: ignore[type-var]
320320

321321
assert take(10, count(sys.maxsize - 5)) == list(range(sys.maxsize - 5, sys.maxsize + 5))
322322
assert take(10, count(-sys.maxsize - 5)) == list(range(-sys.maxsize - 5, -sys.maxsize + 5))
@@ -364,10 +364,10 @@ def test_count_with_stride():
364364
assert lzip("abc", count(step=-1)) == [('a', 0), ('b', -1), ('c', -2)]
365365

366366
with pytest.raises(TypeError, match="a number is required"):
367-
count('a', 'b') # type: ignore
367+
count('a', 'b') # type: ignore[type-var]
368368

369369
with pytest.raises(TypeError, match="a number is required"):
370-
count(5, 'b') # type: ignore
370+
count(5, 'b') # type: ignore[type-var]
371371

372372
assert lzip("abc", count(2, 0)) == [('a', 2), ('b', 2), ('c', 2)]
373373
assert lzip("abc", count(2, 1)) == [('a', 2), ('b', 3), ('c', 4)]
@@ -474,5 +474,5 @@ def test_subclassing_count():
474474
match="type 'domdf_python_tools.iterative.count' is not an acceptable base type",
475475
):
476476

477-
class MyCount(CountType): # type: ignore
477+
class MyCount(CountType): # type: ignore[valid-type,misc]
478478
pass

0 commit comments

Comments
 (0)
0