Skip to content

Commit 682731f

Browse files
committed
Upgrade project meta data and actions
1 parent 93ffea5 commit 682731f

File tree

19 files changed

+178
-139
lines changed

19 files changed

+178
-139
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
with:
1515
python-version: 3.9
1616
- name: Install flake8
17-
run: pip install --upgrade flake8
17+
run: pip install --upgrade flake8 flake8-pyproject
1818
- name: Run flake8
1919
uses: liskin/gh-problem-matcher-wrap@v1
2020
with:

.pre-commit-config.yaml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,23 @@ ci:
88
autoupdate_schedule: monthly
99

1010
repos:
11-
# - repo: https://github.com/asottile/pyupgrade
12-
# rev: v2.37.3
13-
# hooks:
14-
# - id: pyupgrade
15-
# args: ["--py36-plus"]
16-
#
17-
# - repo: https://github.com/adamchainz/django-upgrade
18-
# rev: '1.7.0'
19-
# hooks:
20-
# - id: django-upgrade
21-
# args: [--target-version, "2.2"]
11+
- repo: https://github.com/asottile/pyupgrade
12+
rev: v2.37.3
13+
hooks:
14+
- id: pyupgrade
15+
args: ["--py39-plus"]
16+
17+
- repo: https://github.com/adamchainz/django-upgrade
18+
rev: '1.7.0'
19+
hooks:
20+
- id: django-upgrade
21+
args: [--target-version, "3.2"]
2222

2323
- repo: https://github.com/PyCQA/flake8
2424
rev: 7.1.1
2525
hooks:
2626
- id: flake8
27+
additional_dependencies: [flake8-pyproject]
2728

2829
- repo: https://github.com/asottile/yesqa
2930
rev: v1.5.0

aldryn_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def to_settings(self, data, settings):
2424
settings.setdefault('MEDIA_HEADERS', []).insert(0, (
2525
r'filer_public(?:_thumbnails)?/.*',
2626
{
27-
'Cache-Control': 'public, max-age={}'.format(86400 * 365),
27+
'Cache-Control': f'public, max-age={86400 * 365}',
2828
},
2929
))
3030

@@ -34,12 +34,12 @@ def to_settings(self, data, settings):
3434
settings['THUMBNAIL_CACHE_DIMENSIONS'] = True
3535

3636
# Swap scale and crop for django-filer version
37-
settings['THUMBNAIL_PROCESSORS'] = tuple([
37+
settings['THUMBNAIL_PROCESSORS'] = tuple(
3838
processor
3939
if processor != 'easy_thumbnails.processors.scale_and_crop'
4040
else 'filer.thumbnail_processors.scale_and_crop_with_subject_location'
4141
for processor in EasyThumbnailSettings.THUMBNAIL_PROCESSORS
42-
])
42+
)
4343

4444
# easy_thumbnails uses django's default storage backend (local file
4545
# system storage) by default, even if the DEFAULT_FILE_STORAGE setting

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
# General information about the project.
5959
project = 'django-filer'
60-
copyright = '%s, Stefan Foulis' % (datetime.date.today().year,)
60+
copyright = f'{datetime.date.today().year}, Stefan Foulis'
6161

6262
# The version info for the project you're documenting, acts as replacement for
6363
# |version| and |release|, also used in various other places throughout the

filer/admin/patched/admin_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def format_callback(obj):
4040
has_admin = obj.__class__ in admin_site._registry
4141
opts = obj._meta
4242

43-
no_edit_link = '%s: %s' % (capfirst(opts.verbose_name),
43+
no_edit_link = '{}: {}'.format(capfirst(opts.verbose_name),
4444
force_str(obj))
4545

4646
if has_admin:
@@ -54,7 +54,7 @@ def format_callback(obj):
5454
# Change url doesn't exist -- don't display link to edit
5555
return no_edit_link
5656

57-
p = '%s.%s' % (opts.app_label,
57+
p = '{}.{}'.format(opts.app_label,
5858
get_permission_codename('delete', opts))
5959
if not user.has_perm(p):
6060
perms_needed.add(opts.verbose_name)

filer/cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def clear_folder_permission_cache(user: UserModel, permission: typing.Optional[s
7171
cache.delete(get_folder_perm_cache_key(user, permission))
7272

7373

74-
def update_folder_permission_cache(user: UserModel, permission: str, id_list: typing.List[int]) -> None:
74+
def update_folder_permission_cache(user: UserModel, permission: str, id_list: list[int]) -> None:
7575
"""
7676
Updates the cached folder permissions for a given user and permission.
7777

filer/management/commands/generate_thumbnails.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ def handle(self, *args, **options):
1717
image = None
1818
try:
1919
image = Image.objects.get(pk=pk)
20-
self.stdout.write(u'Processing image {0} / {1} {2}'.format(idx + 1, total, image))
20+
self.stdout.write(f'Processing image {idx + 1} / {total} {image}')
2121
self.stdout.flush()
2222
image.thumbnails
2323
image.icons
24-
except IOError as e:
25-
self.stderr.write('Failed to generate thumbnails: {0}'.format(str(e)))
24+
except OSError as e:
25+
self.stderr.write(f'Failed to generate thumbnails: {str(e)}')
2626
self.stderr.flush()
2727
finally:
2828
del image

filer/management/commands/import_files.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def import_file(self, file_obj, folder):
4747
if created:
4848
self.file_created += 1
4949
if self.verbosity >= 2:
50-
print("file_created #%s / image_created #%s -- file : %s -- created : %s" % (self.file_created,
50+
print("file_created #{} / image_created #{} -- file : {} -- created : {}".format(self.file_created,
5151
self.image_created,
5252
obj, created))
5353
return obj
@@ -70,7 +70,7 @@ def get_or_create_folder(self, folder_names):
7070
if created:
7171
self.folder_created += 1
7272
if self.verbosity >= 2:
73-
print("folder_created #%s folder : %s -- created : %s" % (self.folder_created, current_parent, created))
73+
print(f"folder_created #{self.folder_created} folder : {current_parent} -- created : {created}")
7474
return current_parent
7575

7676
def walker(self, path=None, base_folder=None):
@@ -84,9 +84,9 @@ def walker(self, path=None, base_folder=None):
8484
path = os.path.normpath(path)
8585
if base_folder:
8686
base_folder = os.path.normpath(base_folder)
87-
print("The directory structure will be imported in %s" % (base_folder,))
87+
print(f"The directory structure will be imported in {base_folder}")
8888
if self.verbosity >= 1:
89-
print("Import the folders and files in %s" % (path,))
89+
print(f"Import the folders and files in {path}")
9090
root_folder_name = os.path.basename(path)
9191
for root, dirs, files in os.walk(path):
9292
rel_folders = root.partition(path)[2].strip(os.path.sep).split(os.path.sep)

filer/migrations/0001_initial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class Migration(migrations.Migration):
104104
),
105105
migrations.AlterUniqueTogether(
106106
name='folder',
107-
unique_together=set([('parent', 'name')]),
107+
unique_together={('parent', 'name')},
108108
),
109109
migrations.AddField(
110110
model_name='file',

filer/server/backends/default.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def serve(self, request, filer_file, **kwargs):
2424
# Respect the If-Modified-Since header.
2525
statobj = os.stat(fullpath)
2626
response_params = {'content_type': filer_file.mime_type}
27-
if not was_modified_since(request.META.get('HTTP_IF_MODIFIED_SINCE'),
27+
if not was_modified_since(request.headers.get('if-modified-since'),
2828
statobj[stat.ST_MTIME]):
2929
return HttpResponseNotModified(**response_params)
3030
response = HttpResponse(open(fullpath, 'rb').read(), **response_params)

0 commit comments

Comments
 (0)