Skip to content

Commit 05fb2b1

Browse files
🏷️ Use modern typing syntax
1 parent d33981f commit 05fb2b1

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

privates/admin.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Generic, Optional, Sequence, Type, TypeVar
1+
from typing import Generic, Sequence, TypeVar
22

33
import django.db.models.options
44
from django.contrib.admin import AdminSite
@@ -24,7 +24,7 @@ class PrivateMediaMixin(Generic[_ModelT]):
2424
in the admin URL configuration (automatically).
2525
"""
2626

27-
private_media_fields: Optional[Sequence[str]] = None
27+
private_media_fields: Sequence[str] | None = None
2828
private_media_no_download_fields: Sequence[str] = tuple()
2929
"""
3030
A list of field names for which downloads are forbidden.
@@ -33,17 +33,17 @@ class PrivateMediaMixin(Generic[_ModelT]):
3333
custom widget. You can block this by specifying the name of the field(s) that should
3434
only be writable and not downloadable.
3535
"""
36-
private_media_permission_required: Optional[str] = None
36+
private_media_permission_required: str | None = None
3737
private_media_view_class = PrivateMediaView
3838
"""
3939
The Django view class to use for private media field content download views.
4040
"""
4141
private_media_file_widget = PrivateFileWidget
4242
# options passed through to sendfile, as a dict
43-
private_media_view_options: Optional[dict] = None
43+
private_media_view_options: dict | None = None
4444

4545
admin_site: AdminSite
46-
model: Type[_ModelT]
46+
model: type[_ModelT]
4747
opts: django.db.models.options.Options
4848

4949
def get_private_media_fields(self) -> Sequence[str]:

privates/views.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Optional
2-
31
from django.contrib.auth.mixins import PermissionRequiredMixin
42
from django.views.generic import DetailView
53

@@ -25,7 +23,7 @@ class PrivateMediaView(PermissionRequiredMixin, DetailView):
2523
2624
The path (on-disk) of the file is passed along to :func:`django_sendfile.sendfile`.
2725
"""
28-
sendfile_options: Optional[dict] = None
26+
sendfile_options: dict | None = None
2927
"""
3028
Additional options for :func:`django_sendfile.sendfile`.
3129
"""

privates/widgets.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, Optional, Union
1+
from typing import Any
22

33
from django.contrib.admin.widgets import AdminFileWidget
44
from django.core.files.uploadedfile import UploadedFile
@@ -15,8 +15,8 @@ def __init__(self, *args, **kwargs):
1515
def get_context(
1616
self,
1717
name: str,
18-
value: Optional[Union[FieldFile, UploadedFile]],
19-
attrs: Optional[Dict[str, Any]],
18+
value: FieldFile | UploadedFile | None,
19+
attrs: dict[str, Any] | None,
2020
):
2121
"""
2222
Return value-related substitutions.

0 commit comments

Comments
 (0)