Skip to content

Commit 85771f2

Browse files
committed
Mark Storage.url overrides as keyword-only arguments
This was already implicitly encouraged by the documentation and API structure, but this change ensures that callers will always pass arguments correctly. Since all additional arguments to `.url` are non-standard (compared to Django `Storage`) and vary across Django-Storages subclasses, calling with positional arguments should be disallowed. This is technically a breaking change for anyone using positional arguments, though the fix should be obvious.
1 parent ca89a94 commit 85771f2

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

storages/backends/azure_storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def _expire_at(self, expire):
293293
# azure expects time in UTC
294294
return datetime.utcnow() + timedelta(seconds=expire)
295295

296-
def url(self, name, expire=None, parameters=None, mode="r"):
296+
def url(self, name, *, expire=None, parameters=None, mode="r"):
297297
name = self._get_valid_path(name)
298298
params = parameters or {}
299299
permission = BlobSasPermissions.from_string(mode)

storages/backends/gcloud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def get_created_time(self, name):
309309
created = blob.time_created
310310
return created if setting("USE_TZ") else timezone.make_naive(created)
311311

312-
def url(self, name, parameters=None):
312+
def url(self, name, *, parameters=None):
313313
"""
314314
Return public URL or a signed URL for the Blob.
315315

storages/backends/s3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ def get_modified_time(self, name):
665665
else:
666666
return make_naive(entry.last_modified)
667667

668-
def url(self, name, parameters=None, expire=None, http_method=None):
668+
def url(self, name, *, parameters=None, expire=None, http_method=None):
669669
# Preserve the trailing slash after normalizing the path.
670670
name = self._normalize_name(clean_name(name))
671671
params = parameters.copy() if parameters else {}

0 commit comments

Comments
 (0)