Skip to content

Commit 272bbe2

Browse files
src/__init__.py: avoid problems with type hint on Python-3.8.
On Python 3.9, `collections.abc.Iterable[Page]` fails with `TypeError: 'ABCMeta' object is not subscriptable`.
1 parent 6b7673f commit 272bbe2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5037,7 +5037,13 @@ def pagemode(self) -> str:
50375037
return rc[1][1:]
50385038
return "UseNone"
50395039

5040-
def pages(self, start: OptInt =None, stop: OptInt =None, step: OptInt =None) -> collections.abc.Iterable[Page]:
5040+
if sys.implementation.version < (3, 9):
5041+
# Appending `[Page]` causes `TypeError: 'ABCMeta' object is not subscriptable`.
5042+
_pages_ret = collections.abc.Iterable
5043+
else:
5044+
_pages_ret = collections.abc.Iterable[Page]
5045+
5046+
def pages(self, start: OptInt =None, stop: OptInt =None, step: OptInt =None) -> _pages_ret:
50415047
"""Return a generator iterator over a page range.
50425048

50435049
Arguments have the same meaning as for the range() built-in.

0 commit comments

Comments
 (0)