mirror of
https://github.com/davidhalter/django-stubs.git
synced 2026-02-28 04:22:22 +08:00
update all path related operations to have more accurate types (#713)
This commit is contained in:
39
tests/typecheck/contrib/staticfiles/test_finders.yml
Normal file
39
tests/typecheck/contrib/staticfiles/test_finders.yml
Normal file
@@ -0,0 +1,39 @@
|
||||
- case: test_find_one
|
||||
main: |
|
||||
from django.contrib.staticfiles import finders
|
||||
|
||||
reveal_type(finders.find("filepath")) # N: Revealed type is "Union[builtins.str, builtins.bytes, os.PathLike[Any], None]"
|
||||
|
||||
for finder in finders.get_finders():
|
||||
reveal_type(finder.find("filepath")) # N: Revealed type is "Union[builtins.str, builtins.bytes, os.PathLike[Any], None]"
|
||||
|
||||
reveal_type(finders.FileSystemFinder().find("filepath")) # N: Revealed type is "Union[builtins.str, builtins.bytes, os.PathLike[Any], None]"
|
||||
reveal_type(finders.AppDirectoriesFinder().find("filepath")) # N: Revealed type is "Union[builtins.str, builtins.bytes, os.PathLike[Any], None]"
|
||||
reveal_type(finders.DefaultStorageFinder().find("filepath")) # N: Revealed type is "Union[builtins.str, builtins.bytes, os.PathLike[Any], None]"
|
||||
|
||||
- case: test_find_all
|
||||
main: |
|
||||
from django.contrib.staticfiles import finders
|
||||
|
||||
reveal_type(finders.find("filepath", all=True)) # N: Revealed type is "builtins.list[Union[builtins.str, builtins.bytes, os.PathLike[Any]]]"
|
||||
|
||||
for finder in finders.get_finders():
|
||||
reveal_type(finder.find("filepath", all=True)) # N: Revealed type is "builtins.list[Union[builtins.str, builtins.bytes, os.PathLike[Any]]]"
|
||||
|
||||
reveal_type(finders.FileSystemFinder().find("filepath", all=True)) # N: Revealed type is "builtins.list[Union[builtins.str, builtins.bytes, os.PathLike[Any]]]"
|
||||
reveal_type(finders.AppDirectoriesFinder().find("filepath", all=True)) # N: Revealed type is "builtins.list[Union[builtins.str, builtins.bytes, os.PathLike[Any]]]"
|
||||
reveal_type(finders.DefaultStorageFinder().find("filepath", all=True)) # N: Revealed type is "builtins.list[Union[builtins.str, builtins.bytes, os.PathLike[Any]]]"
|
||||
|
||||
- case: test_file_system_finder # test methods *only* on FileSystemFinder
|
||||
main: |
|
||||
from django.contrib.staticfiles.finders import FileSystemFinder
|
||||
|
||||
finder = FileSystemFinder()
|
||||
reveal_type(finder.find_location(".", "filepath")) # N: Revealed type is "Union[builtins.str, builtins.bytes, os.PathLike[Any], None]"
|
||||
|
||||
- case: test_app_directories_finder # test methods *only* on AppDirectoriesFinder
|
||||
main: |
|
||||
from django.contrib.staticfiles.finders import AppDirectoriesFinder
|
||||
|
||||
finder = AppDirectoriesFinder()
|
||||
reveal_type(finder.find_in_app("app", "filepath")) # N: Revealed type is "Union[builtins.str, builtins.bytes, os.PathLike[Any], None]"
|
||||
Reference in New Issue
Block a user