Skip to content

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

New issue

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

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

Already on GitHub? # to your account

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:

JHSaunders added a commit to relycomply/django-plotly-dash that referenced this issue Apr 10, 2025
The all flag has been deprecated and the find_all flag is being used in Django 5.2.

See: typeddjango/django-stubs#2495
GibbsConsulting pushed a commit to GibbsConsulting/django-plotly-dash that referenced this issue Apr 14, 2025
#524)

The all flag has been deprecated and the find_all flag is being used in Django 5.2.

See: typeddjango/django-stubs#2495
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

No branches or pull requests

1 participant