|
1 |
| -from typing import Any, Iterable, Iterator, List, Mapping, Optional, Union, overload |
| 1 | +import os |
| 2 | +from typing import Any, Iterable, Iterator, List, Mapping, Optional, Tuple, Type, Union, overload |
2 | 3 |
|
3 | 4 | from django.core.checks.messages import CheckMessage
|
4 | 5 | from django.core.files.storage import Storage
|
5 | 6 | from typing_extensions import Literal
|
6 | 7 |
|
| 8 | +_PathType = Union[str, bytes, os.PathLike] |
7 | 9 | searched_locations: Any
|
8 | 10 |
|
9 | 11 | class BaseFinder:
|
10 | 12 | def check(self, **kwargs: Any) -> List[CheckMessage]: ...
|
11 |
| - def find(self, path: str, all: bool = ...) -> Optional[Any]: ... |
| 13 | + @overload |
| 14 | + def find(self, path: _PathType, all: Literal[True]) -> List[_PathType]: ... |
| 15 | + @overload |
| 16 | + def find(self, path: _PathType, all: Literal[False] = ...) -> Optional[_PathType]: ... |
12 | 17 | def list(self, ignore_patterns: Any) -> Iterable[Any]: ...
|
13 | 18 |
|
14 | 19 | class FileSystemFinder(BaseFinder):
|
15 |
| - locations: List[Any] = ... |
| 20 | + locations: List[Tuple[str, _PathType]] = ... |
16 | 21 | storages: Mapping[str, Any] = ...
|
17 | 22 | def __init__(self, app_names: None = ..., *args: Any, **kwargs: Any) -> None: ...
|
18 |
| - def find_location(self, root: str, path: str, prefix: str = ...) -> Optional[str]: ... |
| 23 | + def find_location(self, root: _PathType, path: _PathType, prefix: str = ...) -> Optional[_PathType]: ... |
19 | 24 |
|
20 | 25 | class AppDirectoriesFinder(BaseFinder):
|
21 |
| - storage_class: Any = ... |
| 26 | + storage_class: Type[Storage] = ... |
22 | 27 | source_dir: str = ...
|
23 | 28 | apps: List[str] = ...
|
24 |
| - storages: Mapping[str, Any] = ... |
| 29 | + storages: Mapping[str, Storage] = ... |
25 | 30 | def __init__(self, app_names: None = ..., *args: Any, **kwargs: Any) -> None: ...
|
26 |
| - def find_in_app(self, app: str, path: str) -> Optional[str]: ... |
| 31 | + def find_in_app(self, app: str, path: _PathType) -> Optional[_PathType]: ... |
27 | 32 |
|
28 | 33 | class BaseStorageFinder(BaseFinder):
|
29 | 34 | storage: Storage = ...
|
30 | 35 | def __init__(self, storage: Optional[Storage] = ..., *args: Any, **kwargs: Any) -> None: ...
|
31 | 36 |
|
32 | 37 | class DefaultStorageFinder(BaseStorageFinder): ...
|
33 | 38 |
|
34 |
| -def find(path: str, all: bool = ...) -> Optional[Union[List[str], str]]: ... |
| 39 | +@overload |
| 40 | +def find(path: str, all: Literal[True]) -> List[_PathType]: ... |
| 41 | +@overload |
| 42 | +def find(path: str, all: Literal[False] = ...) -> Optional[_PathType]: ... |
35 | 43 | def get_finders() -> Iterator[BaseFinder]: ...
|
36 | 44 | @overload
|
37 | 45 | def get_finder(import_path: Literal["django.contrib.staticfiles.finders.FileSystemFinder"]) -> FileSystemFinder: ...
|
|
0 commit comments