Skip to content

Commit 7be53d6

Browse files
skv0zsnegjose-reveni
authored andcommitted
Remove contrib.staticfiles finders from allowlist 52. Fix tests and stubs. (typeddjango#2684)
1 parent 2542409 commit 7be53d6

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

django-stubs/contrib/staticfiles/finders.pyi

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ searched_locations: Any
99
class BaseFinder:
1010
def check(self, **kwargs: Any) -> list[CheckMessage]: ...
1111
@overload
12-
def find(self, path: str, all: Literal[False] = False) -> str | None: ...
12+
def find(self, path: str, find_all: Literal[False] = False) -> str | None: ...
1313
@overload
14-
def find(self, path: str, all: Literal[True]) -> list[str]: ...
14+
def find(self, path: str, find_all: Literal[True]) -> list[str]: ...
1515
def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ...
1616

1717
class FileSystemFinder(BaseFinder):
@@ -20,9 +20,9 @@ class FileSystemFinder(BaseFinder):
2020
def __init__(self, app_names: Sequence[str] | None = None, *args: Any, **kwargs: Any) -> None: ...
2121
def find_location(self, root: str, path: str, prefix: str | None = None) -> str | None: ...
2222
@overload
23-
def find(self, path: str, all: Literal[False] = False) -> str | None: ...
23+
def find(self, path: str, find_all: Literal[False] = False) -> str | None: ...
2424
@overload
25-
def find(self, path: str, all: Literal[True]) -> list[str]: ...
25+
def find(self, path: str, find_all: Literal[True]) -> list[str]: ...
2626
def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ...
2727

2828
class AppDirectoriesFinder(BaseFinder):
@@ -33,27 +33,27 @@ class AppDirectoriesFinder(BaseFinder):
3333
def __init__(self, app_names: Iterable[str] | None = None, *args: Any, **kwargs: Any) -> None: ...
3434
def find_in_app(self, app: str, path: str) -> str | None: ...
3535
@overload
36-
def find(self, path: str, all: Literal[False] = False) -> str | None: ...
36+
def find(self, path: str, find_all: Literal[False] = False) -> str | None: ...
3737
@overload
38-
def find(self, path: str, all: Literal[True]) -> list[str]: ...
38+
def find(self, path: str, find_all: Literal[True]) -> list[str]: ...
3939
def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ...
4040

4141
class BaseStorageFinder(BaseFinder):
4242
storage: Storage
4343
def __init__(self, storage: Storage | None = None, *args: Any, **kwargs: Any) -> None: ...
4444
@overload
45-
def find(self, path: str, all: Literal[False] = False) -> str | None: ...
45+
def find(self, path: str, find_all: Literal[False] = False) -> str | None: ...
4646
@overload
47-
def find(self, path: str, all: Literal[True]) -> list[str]: ...
47+
def find(self, path: str, find_all: Literal[True]) -> list[str]: ...
4848
def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ...
4949

5050
class DefaultStorageFinder(BaseStorageFinder):
5151
storage: Storage
5252
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
5353

5454
@overload
55-
def find(path: str, all: Literal[False] = False) -> str | None: ...
55+
def find(path: str, find_all: Literal[False] = False) -> str | None: ...
5656
@overload
57-
def find(path: str, all: Literal[True]) -> list[str]: ...
57+
def find(path: str, find_all: Literal[True]) -> list[str]: ...
5858
def get_finders() -> Iterator[BaseFinder]: ...
5959
def get_finder(import_path: str) -> BaseFinder: ...

scripts/stubtest/allowlist_todo_django52.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ django.contrib.gis.management.commands.ogrinspect
3838
django.contrib.postgres.aggregates.mixins.OrderableAggMixin.__init__
3939
django.contrib.postgres.indexes.BTreeIndex.__init__
4040
django.contrib.sessions.backends.base.SessionBase.pop
41-
django.contrib.staticfiles.finders.AppDirectoriesFinder.find
42-
django.contrib.staticfiles.finders.BaseFinder.find
43-
django.contrib.staticfiles.finders.BaseStorageFinder.find
44-
django.contrib.staticfiles.finders.FileSystemFinder.find
45-
django.contrib.staticfiles.finders.find
4641
django.core.checks.Tags.commands
4742
django.core.checks.commands
4843
django.core.checks.registry.Tags.commands

tests/typecheck/contrib/staticfiles/test_finders.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
main: |
1616
from django.contrib.staticfiles import finders
1717
18-
reveal_type(finders.find("filepath", all=True)) # N: Revealed type is "builtins.list[builtins.str]"
18+
reveal_type(finders.find("filepath", find_all=True)) # N: Revealed type is "builtins.list[builtins.str]"
1919
2020
for finder in finders.get_finders():
21-
reveal_type(finder.find("filepath", all=True)) # N: Revealed type is "builtins.list[builtins.str]"
21+
reveal_type(finder.find("filepath", find_all=True)) # N: Revealed type is "builtins.list[builtins.str]"
2222
23-
reveal_type(finders.FileSystemFinder().find("filepath", all=True)) # N: Revealed type is "builtins.list[builtins.str]"
24-
reveal_type(finders.AppDirectoriesFinder().find("filepath", all=True)) # N: Revealed type is "builtins.list[builtins.str]"
25-
reveal_type(finders.DefaultStorageFinder().find("filepath", all=True)) # N: Revealed type is "builtins.list[builtins.str]"
23+
reveal_type(finders.FileSystemFinder().find("filepath", find_all=True)) # N: Revealed type is "builtins.list[builtins.str]"
24+
reveal_type(finders.AppDirectoriesFinder().find("filepath", find_all=True)) # N: Revealed type is "builtins.list[builtins.str]"
25+
reveal_type(finders.DefaultStorageFinder().find("filepath", find_all=True)) # N: Revealed type is "builtins.list[builtins.str]"
2626
2727
- case: test_file_system_finder # test methods *only* on FileSystemFinder
2828
main: |

0 commit comments

Comments
 (0)