From 4875bc5179938324d157d9917b3a0bfb5fca8dd1 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 9 Sep 2024 12:52:25 -0400 Subject: [PATCH] Add type annotations for _candidate_paths --- importlib_resources/readers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/importlib_resources/readers.py b/importlib_resources/readers.py index abfcde7..dc649cf 100644 --- a/importlib_resources/readers.py +++ b/importlib_resources/readers.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import collections import contextlib import itertools @@ -5,6 +7,7 @@ import operator import re import warnings +from collections.abc import Iterator from . import abc @@ -150,12 +153,12 @@ def _resolve(cls, path_str) -> abc.Traversable: return dir @classmethod - def _candidate_paths(cls, path_str): + def _candidate_paths(cls, path_str: str) -> Iterator[abc.Traversable]: yield pathlib.Path(path_str) yield from cls._resolve_zip_path(path_str) @staticmethod - def _resolve_zip_path(path_str): + def _resolve_zip_path(path_str: str): for match in reversed(list(re.finditer(r'[\\/]', path_str))): with contextlib.suppress( FileNotFoundError,