File tree Expand file tree Collapse file tree 4 files changed +50
-10
lines changed
Expand file tree Collapse file tree 4 files changed +50
-10
lines changed Original file line number Diff line number Diff line change 5151 python-version :
5252 - " 3.9"
5353 - " 3.10"
54+ - " 3.11"
5455 - " 3.12"
5556 django-version :
5657 - " 4.2" # LTS
7879 python-version :
7980 - " 3.11"
8081 django-version :
81- # LTS gets tested on all OS
82- - " 3.2"
83- - " 4.2"
84- - " 5.0"
82+ # oldest LTS gets tested on all Python versions
83+ - " 5.1"
84+ - " 5.2"
8585 runs-on : ubuntu-latest
8686 steps :
8787 - uses : actions/checkout@v4
Original file line number Diff line number Diff line change 11import functools
22import json
3+ import warnings
34
45from django .conf import settings
56from django .contrib .staticfiles .finders import BaseFinder
@@ -29,9 +30,31 @@ def _check_package_json(self):
2930 ]
3031 return []
3132
32- def find (self , path , all = False ):
33+ def _check_deprecated_find_param (self , find_all , ** kwargs ):
34+ # @todo: remove this after Django 5.2 support is dropped
35+ try :
36+ find_all = kwargs ["all" ]
37+ except KeyError :
38+ pass
39+ else :
40+ try :
41+ from django .utils .deprecation import RemovedInDjango61Warning
42+ except ImportError :
43+ pass
44+ else :
45+ warnings .warn (
46+ "The 'all' argument of the find() method is deprecated in favor of "
47+ "the 'find_all' argument." ,
48+ category = RemovedInDjango61Warning ,
49+ stacklevel = 2 ,
50+ )
51+ return find_all
52+
53+ def find (self , path , find_all = False , ** kwargs ):
54+ find_all = self ._check_deprecated_find_param (find_all , ** kwargs )
55+
3356 if path in self .all :
34- return [path ] if all else path
57+ return [path ] if find_all else path
3558 return [] # this method has a strange return type
3659
3760 def list (self , ignore_patterns ):
Original file line number Diff line number Diff line change @@ -28,12 +28,12 @@ classifiers = [
2828 " Programming Language :: Python :: 3.11" ,
2929 " Programming Language :: Python :: 3.12" ,
3030 " Framework :: Django" ,
31- " Framework :: Django :: 3.2" ,
3231 " Framework :: Django :: 4.2" ,
33- " Framework :: Django :: 5.0" ,
32+ " Framework :: Django :: 5.1" ,
33+ " Framework :: Django :: 5.2" ,
3434]
3535requires-python = " >=3.9"
36- dependencies = [" django>=3 .2.0" ]
36+ dependencies = [" django>=4 .2.0" ]
3737
3838[project .optional-dependencies ]
3939test = [
Original file line number Diff line number Diff line change 1+ import warnings
2+
3+ import django .utils .deprecation
4+ import pytest
15from django .contrib .staticfiles .finders import get_finder
26from django .core .checks import Error
37
@@ -17,9 +21,22 @@ def test_find(self):
1721 self .finder .find ("testapp/static/js/components/index.js" )
1822 == "testapp/static/js/components/index.js"
1923 )
20- assert self .finder .find ("lit-html/lit-html.js" , all = True ) == []
24+ assert self .finder .find ("lit-html/lit-html.js" , find_all = True ) == []
2125 assert self .finder .find ("foo/bar.js" ) == []
2226
27+ @pytest .mark .skipif (
28+ not hasattr (django .utils .deprecation , "RemovedInDjango61Warning" ),
29+ reason = "Django < 5.2" ,
30+ )
31+ def test_find_with_deprecated_param (self ):
32+ with warnings .catch_warnings (record = True ) as w :
33+ warnings .simplefilter ("always" )
34+ result = self .finder .find ("testapp/static/js/index.js" , all = True )
35+ assert len (w ) == 1
36+ assert w [0 ].category == django .utils .deprecation .RemovedInDjango61Warning
37+ assert "deprecated in favor of" in str (w [0 ].message )
38+ assert result == ["testapp/static/js/index.js" ]
39+
2340 def test_list (self ):
2441 all_files = self .finder .list ([])
2542 assert ("testapp/static/js/index.js" , storages .root_storage ) in all_files
You can’t perform that action at this time.
0 commit comments