Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/django-cf/django_cf/db/base_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def last_executed_query(self, cursor, sql, params):
else:
values = tuple(params.values())
values = self._quote_params_for_last_executed_query(values)
params = dict(zip(params, values))
params = dict(zip(params, values, strict=True))
try:
return sql % params
except Exception:
Expand Down
17 changes: 7 additions & 10 deletions packages/django-cf/django_cf/storage/r2.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,16 @@ def listdir(self, path):
bucket = self._get_bucket()
result = run_sync(bucket.list({"prefix": full_path, "delimiter": "/"}))

directories = []
files = []

delimited_prefixes = result.get("delimitedPrefixes", [])
for delimited_prefix in delimited_prefixes:
directories.append(
os.path.basename(delimited_prefix.replace(full_path, "", 1).rstrip("/"))
)
directories = [
os.path.basename(delimited_prefix.replace(full_path, "", 1).rstrip("/"))
for delimited_prefix in delimited_prefixes
]

objects = result.get("objects", [])
for obj in objects:
if not obj.key.endswith("/"):
files.append(os.path.basename(obj.key))
files = [
os.path.basename(obj.key) for obj in objects if not obj.key.endswith("/")
]

return directories, files

Expand Down
2 changes: 0 additions & 2 deletions packages/django-cf/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ lint.extend-ignore = [
# Deferred: satisfying these requires behavioural or structural changes to
# code imported from https://github.com/G4brym/django-cf, so they are turned
# off to keep the lint adoption commit mechanical. Re-enable one rule per PR.
"B905", # `zip(strict=True)` can raise where the loose zip silently truncates
"PERF401", # manual-list-comprehension; needs a loop rewrite
"PLR0912", # too many branches; needs decomposition
"PLR0913", # too many arguments; signature change
"PLR2004", # magic value comparison; needs named constants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ async def iterate_view(request):

order_field = "-value" if request.GET.get("direction") == "desc" else "value"

values = []
queryset = AsgiD1Record.objects.using("d1").order_by(order_field)
async for record in queryset:
values.append(record.value)
values = [record.value async for record in queryset]

return JsonResponse({"values": values})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,11 @@ def test_iterator_chunk_size_one_survives_nested_foreign_key_queries(self):
parent_id=second_parent.pk, value="two"
)

seen = []
queryset = D1CursorChild.objects.using("d1").order_by("id")
for child in queryset.iterator(chunk_size=1):
seen.append((child.value, child.parent.name))
seen = [
(child.value, child.parent.name)
for child in queryset.iterator(chunk_size=1)
]

assert sorted(seen) == [("one", "alpha"), ("two", "beta")]

Expand Down
Loading