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

@@ -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]"