Skip to content

Commit

Permalink
Add type annotations for _candidate_paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Sep 9, 2024
1 parent d84ca37 commit 4875bc5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions importlib_resources/readers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from __future__ import annotations

import collections
import contextlib
import itertools
import pathlib
import operator
import re
import warnings
from collections.abc import Iterator

from . import abc

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 4875bc5

Please sign in to comment.