From 56254c97bda593aff4986884f7a18ca559f0c3af Mon Sep 17 00:00:00 2001 From: Dominic Davis-Foster Date: Thu, 12 Jan 2023 15:52:42 +0000 Subject: [PATCH 1/2] Make some type: ignore comments more specific --- domdf_python_tools/bases.py | 10 +++++----- tests/test_getters.py | 6 +++--- tests/test_iterative.py | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/domdf_python_tools/bases.py b/domdf_python_tools/bases.py index c01515d7..d25b380e 100644 --- a/domdf_python_tools/bases.py +++ b/domdf_python_tools/bases.py @@ -106,7 +106,7 @@ def __getstate__(self) -> Dict[str, _V]: return self.__dict__ def __setstate__(self, state): - self.__init__(**state) # type: ignore + self.__init__(**state) # type: ignore[misc] def __copy__(self): return self.__class__(**self.__dict__) @@ -219,7 +219,7 @@ def __setitem__(self, i: int, o: _T) -> None: ... def __setitem__(self, i: slice, o: Iterable[_T]) -> None: ... def __setitem__(self, i: Union[int, slice], item: Union[_T, Iterable[_T]]) -> None: - self.data[i] = item # type: ignore + self.data[i] = item # type: ignore[index, assignment] def __delitem__(self, i: Union[int, slice]): del self.data[i] @@ -422,7 +422,7 @@ def __sub__(self: _F, other: float) -> _F: def __mul__(self: _F, other: float) -> _F: return self.__class__(float(self).__mul__(other)) - def __floordiv__(self: _F, other: float) -> _F: # type: ignore + def __floordiv__(self: _F, other: float) -> _F: # type: ignore[override] return self.__class__(float(self).__floordiv__(other)) def __truediv__(self: _F, other: float) -> _F: @@ -432,7 +432,7 @@ def __mod__(self: _F, other: float) -> _F: return self.__class__(float(self).__mod__(other)) def __divmod__(self: _F, other: float) -> Tuple[_F, _F]: - return tuple(self.__class__(x) for x in float(self).__divmod__(other)) # type: ignore + return tuple(self.__class__(x) for x in float(self).__divmod__(other)) # type: ignore[return-value] def __pow__(self: _F, other: float, mod=None) -> _F: return self.__class__(float(self).__pow__(other, mod)) @@ -446,7 +446,7 @@ def __rsub__(self: _F, other: float) -> _F: def __rmul__(self: _F, other: float) -> _F: return self.__class__(float(self).__rmul__(other)) - def __rfloordiv__(self: _F, other: float) -> _F: # type: ignore + def __rfloordiv__(self: _F, other: float) -> _F: # type: ignore[override] return self.__class__(float(self).__rfloordiv__(other)) def __rtruediv__(self: _F, other: float) -> _F: diff --git a/tests/test_getters.py b/tests/test_getters.py index 9ddd208c..dd433626 100644 --- a/tests/test_getters.py +++ b/tests/test_getters.py @@ -55,13 +55,13 @@ class A: f([a, b]) with pytest.raises(TypeError, match="attribute name must be a string"): - attrgetter(0, 2) # type: ignore + attrgetter(0, 2) # type: ignore[arg-type] with pytest.raises(TypeError, match="'idx' must be an integer"): - attrgetter("hello", 0) # type: ignore + attrgetter("hello", 0) # type: ignore[arg-type] with pytest.raises(TypeError, match=r"__init__\(\) missing 1 required positional argument: 'attr'"): - attrgetter(0) # type: ignore + attrgetter(0) # type: ignore[call-arg] f = attrgetter(1, "name") diff --git a/tests/test_iterative.py b/tests/test_iterative.py index 06a85c9c..ca7b3524 100644 --- a/tests/test_iterative.py +++ b/tests/test_iterative.py @@ -313,10 +313,10 @@ def test_count(): assert take(2, zip("abc", count(-3))) == [('a', -3), ('b', -2)] with pytest.raises(TypeError, match=r"count\(\) takes from 0 to 2 positional arguments but 3 were given"): - count(2, 3, 4) # type: ignore + count(2, 3, 4) # type: ignore[call-arg] with pytest.raises(TypeError, match="a number is required"): - count('a') # type: ignore + count('a') # type: ignore[type-var] assert take(10, count(sys.maxsize - 5)) == list(range(sys.maxsize - 5, sys.maxsize + 5)) assert take(10, count(-sys.maxsize - 5)) == list(range(-sys.maxsize - 5, -sys.maxsize + 5)) @@ -364,10 +364,10 @@ def test_count_with_stride(): assert lzip("abc", count(step=-1)) == [('a', 0), ('b', -1), ('c', -2)] with pytest.raises(TypeError, match="a number is required"): - count('a', 'b') # type: ignore + count('a', 'b') # type: ignore[type-var] with pytest.raises(TypeError, match="a number is required"): - count(5, 'b') # type: ignore + count(5, 'b') # type: ignore[type-var] assert lzip("abc", count(2, 0)) == [('a', 2), ('b', 2), ('c', 2)] assert lzip("abc", count(2, 1)) == [('a', 2), ('b', 3), ('c', 4)] @@ -474,5 +474,5 @@ def test_subclassing_count(): match="type 'domdf_python_tools.iterative.count' is not an acceptable base type", ): - class MyCount(CountType): # type: ignore + class MyCount(CountType): # type: ignore[valid-type,misc] pass From 7a556e277e79cb69f462531ad49bde6acf823f59 Mon Sep 17 00:00:00 2001 From: Dominic Davis-Foster Date: Thu, 12 Jan 2023 16:49:39 +0000 Subject: [PATCH 2/2] Always use Python 3.8 for tox in GitHub Actions --- .github/workflows/python_ci_linux.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python_ci_linux.yml b/.github/workflows/python_ci_linux.yml index d1662b09..24666d8f 100644 --- a/.github/workflows/python_ci_linux.yml +++ b/.github/workflows/python_ci_linux.yml @@ -60,7 +60,9 @@ jobs: if: ${{ steps.changes.outputs.code == 'true' || steps.changes.outcome == 'skipped' }} uses: "actions/setup-python@v4" with: - python-version: "${{ matrix.config.python-version }}" + python-version: | + ${{ matrix.config.python-version }} + 3.8 - name: Install dependencies 🔧 if: steps.setup-python.outcome == 'success'