Skip to content

Commit 75876c7

Browse files
committed
Downgrade mypy for Python 3.7
1 parent afaf397 commit 75876c7

9 files changed

+21
-19
lines changed

boltons/cacheutils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -798,15 +798,15 @@ def iterkeys(self) -> Iterator[_KT]:
798798
def keys(self) -> list[_KT]:
799799
return list(self.iterkeys())
800800

801-
def itervalues(self) -> Generator[int]:
801+
def itervalues(self) -> Generator[int, None, None]:
802802
count_map = self._count_map
803803
for k in count_map:
804804
yield count_map[k][0]
805805

806806
def values(self) -> list[int]:
807807
return list(self.itervalues())
808808

809-
def iteritems(self) -> Generator[tuple[_KT, int]]:
809+
def iteritems(self) -> Generator[tuple[_KT, int], None, None]:
810810
count_map = self._count_map
811811
for k in count_map:
812812
yield (k, count_map[k][0])

boltons/dictutils.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ def _remove_all(self, k):
462462
cell[PREV][NEXT], cell[NEXT][PREV] = cell[NEXT], cell[PREV]
463463
del self._map[k]
464464

465-
def iteritems(self, multi: bool = False) -> Generator[tuple[_KT, _VT]]:
465+
def iteritems(self, multi: bool = False) -> Generator[tuple[_KT, _VT], None, None]:
466466
"""Iterate over the OMD's items in insertion order. By default,
467467
yields only the most-recently inserted value for each key. Set
468468
*multi* to ``True`` to get all inserted items.
@@ -477,7 +477,7 @@ def iteritems(self, multi: bool = False) -> Generator[tuple[_KT, _VT]]:
477477
for key in self.iterkeys():
478478
yield key, self[key]
479479

480-
def iterkeys(self, multi: bool = False) -> Generator[_KT]:
480+
def iterkeys(self, multi: bool = False) -> Generator[_KT, None, None]:
481481
"""Iterate over the OMD's keys in insertion order. By default, yields
482482
each key once, according to the most recent insertion. Set
483483
*multi* to ``True`` to get all keys, including duplicates, in
@@ -499,7 +499,7 @@ def iterkeys(self, multi: bool = False) -> Generator[_KT]:
499499
yield k
500500
curr = curr[NEXT]
501501

502-
def itervalues(self, multi: bool = False) -> Generator[_VT]:
502+
def itervalues(self, multi: bool = False) -> Generator[_VT, None, None]:
503503
"""Iterate over the OMD's values in insertion order. By default,
504504
yields the most-recently inserted value per unique key. Set
505505
*multi* to ``True`` to get all values according to insertion
@@ -742,15 +742,15 @@ def _remove_all(self, k):
742742
cell[PREV][NEXT], cell[NEXT][PREV] = cell[NEXT], cell[PREV]
743743
cell[PREV][SNEXT] = cell[SNEXT]
744744

745-
def iteritems(self, multi: bool = False) -> Generator[tuple[_KT, _VT]]:
745+
def iteritems(self, multi: bool = False) -> Generator[tuple[_KT, _VT], None, None]:
746746
next_link = NEXT if multi else SNEXT
747747
root = self.root
748748
curr = root[next_link]
749749
while curr is not root:
750750
yield curr[KEY], curr[VALUE]
751751
curr = curr[next_link]
752752

753-
def iterkeys(self, multi: bool = False) -> Generator[_KT]:
753+
def iterkeys(self, multi: bool = False) -> Generator[_KT, None, None]:
754754
next_link = NEXT if multi else SNEXT
755755
root = self.root
756756
curr = root[next_link]
@@ -1017,7 +1017,7 @@ def replace(self, key: _KT, newkey: _KT) -> None:
10171017
revset.remove(key)
10181018
revset.add(newkey)
10191019

1020-
def iteritems(self) -> Generator[tuple[_KT, _VT]]:
1020+
def iteritems(self) -> Generator[tuple[_KT, _VT], None, None]:
10211021
for key in self.data:
10221022
for val in self.data[key]:
10231023
yield key, val

boltons/fileutils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ def __exit__(self, exc_type: type[BaseException] | None, exc_val: BaseException
498498
return
499499

500500

501-
def iter_find_files(directory: str, patterns: str | Iterable[str], ignored: str | Iterable[str] | None = None, include_dirs: bool = False, max_depth: int | None = None) -> Generator[str]:
501+
def iter_find_files(directory: str, patterns: str | Iterable[str], ignored: str | Iterable[str] | None = None, include_dirs: bool = False, max_depth: int | None = None) -> Generator[str, None, None]:
502502
"""Returns a generator that yields file paths under a *directory*,
503503
matching *patterns* using `glob`_ syntax (e.g., ``*.txt``). Also
504504
supports *ignored* patterns.

boltons/iterutils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def postprocess(chk): return bytes(chk)
359359
return
360360

361361

362-
def chunk_ranges(input_size: int, chunk_size: int, input_offset: int = 0, overlap_size: int = 0, align: bool = False) -> Generator[tuple[int, int]]:
362+
def chunk_ranges(input_size: int, chunk_size: int, input_offset: int = 0, overlap_size: int = 0, align: bool = False) -> Generator[tuple[int, int], None, None]:
363363
"""Generates *chunk_size*-sized chunk ranges for an input with length *input_size*.
364364
Optionally, a start of the input can be set via *input_offset*, and
365365
and overlap between the chunks may be specified via *overlap_size*.
@@ -1315,7 +1315,7 @@ def get_path(root, path, default=_UNSET):
13151315
cur = cur[seg]
13161316
except (KeyError, IndexError) as exc:
13171317
raise PathAccessError(exc, seg, path)
1318-
except TypeError as exc:
1318+
except TypeError:
13191319
# either string index in a list, or a parent that
13201320
# doesn't support indexing
13211321
try:

boltons/jsonutils.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@
5252
__all__ = ['JSONLIterator', 'reverse_iter_lines']
5353

5454
@overload
55-
def reverse_iter_lines(file_obj: IO[bytes], blocksize: int = DEFAULT_BLOCKSIZE, preseek: bool = True, encoding: None = None) -> Generator[bytes]: ...
55+
def reverse_iter_lines(file_obj: IO[bytes], blocksize: int = DEFAULT_BLOCKSIZE, preseek: bool = True, encoding: None = None) -> Generator[bytes, None, None]: ...
5656
@overload
57-
def reverse_iter_lines(file_obj: IO[str], blocksize: int = DEFAULT_BLOCKSIZE, preseek: bool = True, *, encoding: str) -> Generator[str]: ...
57+
def reverse_iter_lines(file_obj: IO[str], blocksize: int = DEFAULT_BLOCKSIZE, preseek: bool = True, *, encoding: str) -> Generator[str, None, None]: ...
5858
@overload
59-
def reverse_iter_lines(file_obj: IO[str], blocksize: int, preseek: bool, encoding: str) -> Generator[str]: ...
60-
def reverse_iter_lines(file_obj: IO[bytes] | IO[str], blocksize: int = DEFAULT_BLOCKSIZE, preseek: bool = True, encoding: str | None = None) -> Generator[bytes] | Generator[str]:
59+
def reverse_iter_lines(file_obj: IO[str], blocksize: int, preseek: bool, encoding: str) -> Generator[str, None, None]: ...
60+
def reverse_iter_lines(file_obj: IO[bytes] | IO[str], blocksize: int = DEFAULT_BLOCKSIZE, preseek: bool = True, encoding: str | None = None) -> Generator[bytes, None, None] | Generator[str, None, None]:
6161
"""Returns an iterator over the lines from a file object, in
6262
reverse order, i.e., last line first, first line last. Uses the
6363
:meth:`file.seek` method of file objects, and is tested compatible with

boltons/strutils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ def gzip_bytes(bytestring: ReadableBuffer, level: int = 6) -> bytes:
666666
re.UNICODE)
667667

668668

669-
def iter_splitlines(text: str) -> Generator[str]:
669+
def iter_splitlines(text: str) -> Generator[str, None, None]:
670670
r"""Like :meth:`str.splitlines`, but returns an iterator of lines
671671
instead of a list. Also similar to :meth:`file.next`, as that also
672672
lazily reads and yields lines from a file.

boltons/timeutils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def strpdate(string: str, format: str) -> date:
298298
return whence.date()
299299

300300

301-
def daterange(start: date, stop: date, step: int = 1, inclusive: bool = False) -> Generator[date]:
301+
def daterange(start: date, stop: date, step: int = 1, inclusive: bool = False) -> Generator[date, None, None]:
302302
"""In the spirit of :func:`range` and :func:`xrange`, the `daterange`
303303
generator that yields a sequence of :class:`~datetime.date`
304304
objects, starting at *start*, incrementing by *step*, until *stop*

mypy.ini

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ disable_error_code =
2727
# check_untyped_defs = true
2828

2929
[mypy-sphinx_rtd_theme.*]
30-
follow_untyped_imports = true
30+
ignore_missing_imports = True
31+
# use the following with mypy 1.15+
32+
# follow_untyped_imports = true

requirements-test.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
coverage==7.2.7
2-
mypy[faster-cache]==1.15.0
2+
mypy==1.8.0
33
pytest==7.4.4; python_version < "3.8"
44
pytest==8.3.4; python_version >= "3.8"
55
pytest-cov==4.1.0

0 commit comments

Comments
 (0)