1
0
mirror of https://github.com/django/django.git synced 2025-10-28 08:06:09 +00:00

Refs #36500 -- Rewrapped long docstrings and block comments via a script.

Rewrapped long docstrings and block comments to 79 characters + newline
using script from https://github.com/medmunds/autofix-w505.
This commit is contained in:
django-bot
2025-07-22 20:41:41 -07:00
committed by nessita
parent 55b0cc2131
commit 69a93a88ed
378 changed files with 2781 additions and 1861 deletions

View File

@@ -755,8 +755,9 @@ class QuerySet(AltersData):
Insert each of the instances into the database. Do *not* call
save() on each of the instances, do not send any pre/post_save
signals, and do not set the primary key attribute if it is an
autoincrement field (except if features.can_return_rows_from_bulk_insert=True).
Multi-table models are not supported.
autoincrement field (except if
features.can_return_rows_from_bulk_insert=True). Multi-table models are
not supported.
"""
# When you bulk insert you don't get the primary keys back (if it's an
# autoincrement, except if can_return_rows_from_bulk_insert=True), so
@@ -774,8 +775,9 @@ class QuerySet(AltersData):
raise ValueError("Batch size must be a positive integer.")
# Check that the parents share the same concrete model with the our
# model to detect the inheritance pattern ConcreteGrandParent ->
# MultiTableParent -> ProxyChild. Simply checking self.model._meta.proxy
# would not identify that case as involving multiple tables.
# MultiTableParent -> ProxyChild. Simply checking
# self.model._meta.proxy would not identify that case as involving
# multiple tables.
for parent in self.model._meta.all_parents:
if parent._meta.concrete_model is not self.model._meta.concrete_model:
raise ValueError("Can't bulk create a multi-table inherited model")
@@ -1302,10 +1304,10 @@ class QuerySet(AltersData):
def _update(self, values):
"""
A version of update() that accepts field objects instead of field names.
Used primarily for model saving and not intended for use by general
code (it requires too much poking around at model internals to be
useful at that level).
A version of update() that accepts field objects instead of field
names. Used primarily for model saving and not intended for use by
general code (it requires too much poking around at model internals to
be useful at that level).
"""
if self.query.is_sliced:
raise TypeError("Cannot update a query once a slice has been taken.")
@@ -2365,9 +2367,9 @@ def prefetch_related_objects(model_instances, *related_lookups):
# Prepare objects:
good_objects = True
for obj in obj_list:
# Since prefetching can re-use instances, it is possible to have
# the same instance multiple times in obj_list, so obj might
# already be prepared.
# Since prefetching can re-use instances, it is possible to
# have the same instance multiple times in obj_list, so obj
# might already be prepared.
if not hasattr(obj, "_prefetched_objects_cache"):
try:
obj._prefetched_objects_cache = {}
@@ -2376,7 +2378,8 @@ def prefetch_related_objects(model_instances, *related_lookups):
# values_list(flat=True), for example (TypeError) or
# a QuerySet subclass that isn't returning Model
# instances (AttributeError), either in Django or a 3rd
# party. prefetch_related() doesn't make sense, so quit.
# party. prefetch_related() doesn't make sense, so
# quit.
good_objects = False
break
if not good_objects:
@@ -2384,8 +2387,9 @@ def prefetch_related_objects(model_instances, *related_lookups):
# Descend down tree
# We assume that objects retrieved are homogeneous (which is the premise
# of prefetch_related), so what applies to first object applies to all.
# We assume that objects retrieved are homogeneous (which is the
# premise of prefetch_related), so what applies to first object
# applies to all.
first_obj = obj_list[0]
to_attr = lookup.get_current_to_attr(level)[0]
prefetcher, descriptor, attr_found, is_fetched = get_prefetcher(
@@ -2462,8 +2466,8 @@ def prefetch_related_objects(model_instances, *related_lookups):
if new_obj is None:
continue
# We special-case `list` rather than something more generic
# like `Iterable` because we don't want to accidentally match
# user models that define __iter__.
# like `Iterable` because we don't want to accidentally
# match user models that define __iter__.
if isinstance(new_obj, list):
new_obj_list.extend(new_obj)
else:
@@ -2528,8 +2532,8 @@ def get_prefetcher(instance, through_attr, to_attr):
if through_attr == to_attr:
is_fetched = rel_obj_descriptor.is_cached
else:
# descriptor doesn't support prefetching, so we go ahead and get
# the attribute on the instance rather than the class to
# descriptor doesn't support prefetching, so we go ahead and
# get the attribute on the instance rather than the class to
# support many related managers
rel_obj = getattr(instance, through_attr)
if hasattr(rel_obj, "get_prefetch_querysets"):
@@ -2556,12 +2560,14 @@ def prefetch_one_level(instances, prefetcher, lookup, level):
# prefetcher must have a method get_prefetch_querysets() which takes a list
# of instances, and returns a tuple:
# (queryset of instances of self.model that are related to passed in instances,
# (queryset of instances of self.model that are related to passed in
# instances,
# callable that gets value to be matched for returned instances,
# callable that gets value to be matched for passed in instances,
# boolean that is True for singly related objects,
# cache or field name to assign to,
# boolean that is True when the previous argument is a cache name vs a field name).
# boolean that is True when the previous argument is a cache name vs a
# field name).
# The 'values to be matched' must be hashable as they will be used
# in a dictionary.
@@ -2601,8 +2607,9 @@ def prefetch_one_level(instances, prefetcher, lookup, level):
to_attr, as_attr = lookup.get_current_to_attr(level)
# Make sure `to_attr` does not conflict with a field.
if as_attr and instances:
# We assume that objects retrieved are homogeneous (which is the premise
# of prefetch_related), so what applies to first object applies to all.
# We assume that objects retrieved are homogeneous (which is the
# premise of prefetch_related), so what applies to first object applies
# to all.
model = instances[0].__class__
try:
model._meta.get_field(to_attr)