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 51
51
python-version :
52
52
- " 3.9"
53
53
- " 3.10"
54
+ - " 3.11"
54
55
- " 3.12"
55
56
django-version :
56
57
- " 4.2" # LTS
78
79
python-version :
79
80
- " 3.11"
80
81
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"
85
85
runs-on : ubuntu-latest
86
86
steps :
87
87
- uses : actions/checkout@v4
Original file line number Diff line number Diff line change 1
1
import functools
2
2
import json
3
+ import warnings
3
4
4
5
from django .conf import settings
5
6
from django .contrib .staticfiles .finders import BaseFinder
@@ -29,9 +30,31 @@ def _check_package_json(self):
29
30
]
30
31
return []
31
32
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
+
33
56
if path in self .all :
34
- return [path ] if all else path
57
+ return [path ] if find_all else path
35
58
return [] # this method has a strange return type
36
59
37
60
def list (self , ignore_patterns ):
Original file line number Diff line number Diff line change @@ -28,12 +28,12 @@ classifiers = [
28
28
" Programming Language :: Python :: 3.11" ,
29
29
" Programming Language :: Python :: 3.12" ,
30
30
" Framework :: Django" ,
31
- " Framework :: Django :: 3.2" ,
32
31
" Framework :: Django :: 4.2" ,
33
- " Framework :: Django :: 5.0" ,
32
+ " Framework :: Django :: 5.1" ,
33
+ " Framework :: Django :: 5.2" ,
34
34
]
35
35
requires-python = " >=3.9"
36
- dependencies = [" django>=3 .2.0" ]
36
+ dependencies = [" django>=4 .2.0" ]
37
37
38
38
[project .optional-dependencies ]
39
39
test = [
Original file line number Diff line number Diff line change
1
+ import warnings
2
+
3
+ import django .utils .deprecation
4
+ import pytest
1
5
from django .contrib .staticfiles .finders import get_finder
2
6
from django .core .checks import Error
3
7
@@ -17,9 +21,22 @@ def test_find(self):
17
21
self .finder .find ("testapp/static/js/components/index.js" )
18
22
== "testapp/static/js/components/index.js"
19
23
)
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 ) == []
21
25
assert self .finder .find ("foo/bar.js" ) == []
22
26
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
+
23
40
def test_list (self ):
24
41
all_files = self .finder .list ([])
25
42
assert ("testapp/static/js/index.js" , storages .root_storage ) in all_files
You can’t perform that action at this time.
0 commit comments