Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update django.contrib.staticfiles.finders.BaseFinder.find() (and subclasses) for all -> find_all argument rename #2495

Open
joshuadavidthomas opened this issue Jan 28, 2025 · 0 comments

Comments

@joshuadavidthomas
Copy link
Contributor

I'm currently implementing a custom static files finder, and have been running into type errors when testing on the first alpha release of Django 5.2.

Looks like in 5.2, the all argument to the find method on all finders has been renamed to find_all. The all argument has been marked as deprecated, slated for removal in Django 6.1.

The stubs for all the finders should be updated to handle both arguments until all has been deprecated.

Current stubs (BaseFinder):

@overload
def find(self, path: str, all: Literal[False] = False) -> str | None: ...
@overload
def find(self, path: str, all: Literal[True]) -> list[str]: ...

Here's my attempt at fixing it (though I'm not totally sure about the overloads, a bit out of my element here):

@overload
def find(self, path: str, all: Literal[False] = False) -> str | None: ...
@overload
def find(self, path: str, all: Literal[True]) -> list[str]: ...
@overload
def find(self, path: str, find_all: Literal[False] = False) -> str | None: ...
@overload
def find(self, path: str, find_all: Literal[True]) -> list[str]: ...
def find(self, path: str, find_all: bool = False, **kwargs: Any) -> str | list[str] | None: ...

Happy to submit a PR for this.

Relevant commits:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant