Skip to content

Commit

Permalink
Add more accurate type annotations for dirs.
Browse files Browse the repository at this point in the history
Though not documented, it's possible for `dirs` to contain
`pathlib.Path`.

`django.template.loaders.app_directories.Loader` is an example for this:
https://github.com/django/django/blob/03eec9ff6cc78e7c1bcf88bb76ecd11f0d433c72/django/template/loaders/app_directories.py
https://github.com/django/django/blob/03eec9ff6cc78e7c1bcf88bb76ecd11f0d433c72/django/template/utils.py#L97-L111

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
  • Loading branch information
PIG208 committed Jul 1, 2022
1 parent c06dab6 commit ec66dfc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions django-stubs/template/loaders/filesystem.pyi
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from typing import Iterator, List, Optional
from pathlib import Path
from typing import Iterator, List, Optional, Union

from django.template.base import Origin
from django.template.engine import Engine

from .base import Loader as BaseLoader

class Loader(BaseLoader):
dirs: Optional[List[str]] = ...
def __init__(self, engine: Engine, dirs: Optional[List[str]] = ...) -> None: ...
def get_dirs(self) -> List[str]: ...
dirs: Optional[List[Union[str, Path]]] = ...
def __init__(self, engine: Engine, dirs: Optional[List[Union[str, Path]]] = ...) -> None: ...
def get_dirs(self) -> List[Union[str, Path]]: ...
def get_contents(self, origin: Origin) -> str: ...
def get_template_sources(self, template_name: str) -> Iterator[Origin]: ...

0 comments on commit ec66dfc

Please sign in to comment.