mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-22 03:41:28 +08:00
update all path related operations to have more accurate types (#713)
This commit is contained in:
@@ -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: ...
|
||||
|
||||
Reference in New Issue
Block a user