update all path related operations to have more accurate types (#713)

This commit is contained in:
Terence Honles
2021-09-11 12:41:16 -07:00
committed by GitHub
parent 799b41fe47
commit fb12560981
2 changed files with 55 additions and 8 deletions

View File

@@ -1,29 +1,34 @@
from typing import Any, Iterable, Iterator, List, Mapping, Optional, Union, overload
import os
from typing import Any, Iterable, Iterator, List, Mapping, Optional, Tuple, Type, Union, overload
from django.core.checks.messages import CheckMessage
from django.core.files.storage import Storage
from typing_extensions import Literal
_PathType = Union[str, bytes, os.PathLike]
searched_locations: Any
class BaseFinder:
def check(self, **kwargs: Any) -> List[CheckMessage]: ...
def find(self, path: str, all: bool = ...) -> Optional[Any]: ...
@overload
def find(self, path: _PathType, all: Literal[True]) -> List[_PathType]: ...
@overload
def find(self, path: _PathType, all: Literal[False] = ...) -> Optional[_PathType]: ...
def list(self, ignore_patterns: Any) -> Iterable[Any]: ...
class FileSystemFinder(BaseFinder):
locations: List[Any] = ...
locations: List[Tuple[str, _PathType]] = ...
storages: Mapping[str, Any] = ...
def __init__(self, app_names: None = ..., *args: Any, **kwargs: Any) -> None: ...
def find_location(self, root: str, path: str, prefix: str = ...) -> Optional[str]: ...
def find_location(self, root: _PathType, path: _PathType, prefix: str = ...) -> Optional[_PathType]: ...
class AppDirectoriesFinder(BaseFinder):
storage_class: Any = ...
storage_class: Type[Storage] = ...
source_dir: str = ...
apps: List[str] = ...
storages: Mapping[str, Any] = ...
storages: Mapping[str, Storage] = ...
def __init__(self, app_names: None = ..., *args: Any, **kwargs: Any) -> None: ...
def find_in_app(self, app: str, path: str) -> Optional[str]: ...
def find_in_app(self, app: str, path: _PathType) -> Optional[_PathType]: ...
class BaseStorageFinder(BaseFinder):
storage: Storage = ...
@@ -31,7 +36,10 @@ class BaseStorageFinder(BaseFinder):
class DefaultStorageFinder(BaseStorageFinder): ...
def find(path: str, all: bool = ...) -> Optional[Union[List[str], str]]: ...
@overload
def find(path: str, all: Literal[True]) -> List[_PathType]: ...
@overload
def find(path: str, all: Literal[False] = ...) -> Optional[_PathType]: ...
def get_finders() -> Iterator[BaseFinder]: ...
@overload
def get_finder(import_path: Literal["django.contrib.staticfiles.finders.FileSystemFinder"]) -> FileSystemFinder: ...