summaryrefslogtreecommitdiff
path: root/django/db/models
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-03 11:20:46 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-03 11:38:46 +0100
commitd55a1e5809b424907528af42bfdfc2991ef11651 (patch)
tree605247aa8b905c148d6e5f480da3f0d2a2eec586 /django/db/models
parent76c80d96f3828a5a3f66842932a5624674ba99a2 (diff)
[4.0.x] Refs #33476 -- Refactored problematic code before reformatting by Black.
In these cases Black produces unexpected results, e.g. def make_random_password( self, length=10, allowed_chars='abcdefghjkmnpqrstuvwxyz' 'ABCDEFGHJKLMNPQRSTUVWXYZ' '23456789', ): or cursor.execute(""" SELECT ... """, [table name], ) Backport of c5cd8783825b5f6384417dac5f3889b4210b7d08 from main.
Diffstat (limited to 'django/db/models')
-rw-r--r--django/db/models/constraints.py3
-rw-r--r--django/db/models/fields/__init__.py3
-rw-r--r--django/db/models/indexes.py3
-rw-r--r--django/db/models/lookups.py3
-rw-r--r--django/db/models/query.py6
-rw-r--r--django/db/models/sql/query.py8
6 files changed, 10 insertions, 16 deletions
diff --git a/django/db/models/constraints.py b/django/db/models/constraints.py
index d36d076346..5abedaf3d1 100644
--- a/django/db/models/constraints.py
+++ b/django/db/models/constraints.py
@@ -40,8 +40,7 @@ class CheckConstraint(BaseConstraint):
self.check = check
if not getattr(check, 'conditional', False):
raise TypeError(
- 'CheckConstraint.check must be a Q instance or boolean '
- 'expression.'
+ 'CheckConstraint.check must be a Q instance or boolean expression.'
)
super().__init__(name)
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index 0e72a09e59..4d2ac900f8 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -101,8 +101,7 @@ class Field(RegisterLookupMixin):
'invalid_choice': _('Value %(value)r is not a valid choice.'),
'null': _('This field cannot be null.'),
'blank': _('This field cannot be blank.'),
- 'unique': _('%(model_name)s with this %(field_label)s '
- 'already exists.'),
+ 'unique': _('%(model_name)s with this %(field_label)s already exists.'),
# Translators: The 'lookup_type' is one of 'date', 'year' or 'month'.
# Eg: "Title must be unique for pub_date year"
'unique_for_date': _("%(field_label)s must be unique for "
diff --git a/django/db/models/indexes.py b/django/db/models/indexes.py
index 9c393ca2c0..e843f9a8cb 100644
--- a/django/db/models/indexes.py
+++ b/django/db/models/indexes.py
@@ -36,8 +36,7 @@ class Index:
raise ValueError('Index.opclasses must be a list or tuple.')
if not expressions and not fields:
raise ValueError(
- 'At least one field or expression is required to define an '
- 'index.'
+ 'At least one field or expression is required to define an index.'
)
if expressions and fields:
raise ValueError(
diff --git a/django/db/models/lookups.py b/django/db/models/lookups.py
index 0f104416de..04c4a4863c 100644
--- a/django/db/models/lookups.py
+++ b/django/db/models/lookups.py
@@ -541,8 +541,7 @@ class IsNull(BuiltinLookup):
def as_sql(self, compiler, connection):
if not isinstance(self.rhs, bool):
raise ValueError(
- 'The QuerySet value for an isnull lookup must be True or '
- 'False.'
+ 'The QuerySet value for an isnull lookup must be True or False.'
)
sql, params = compiler.compile(self.lhs)
if self.rhs:
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 1bc8e2ed2a..b3b81c22f2 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -820,8 +820,7 @@ class QuerySet:
self._not_support_combined_queries('contains')
if self._fields is not None:
raise TypeError(
- 'Cannot call QuerySet.contains() after .values() or '
- '.values_list().'
+ 'Cannot call QuerySet.contains() after .values() or .values_list().'
)
try:
if obj._meta.concrete_model != self.model._meta.concrete_model:
@@ -1611,8 +1610,7 @@ class Prefetch:
)
):
raise ValueError(
- 'Prefetch querysets cannot use raw(), values(), and '
- 'values_list().'
+ 'Prefetch querysets cannot use raw(), values(), and values_list().'
)
if to_attr:
self.prefetch_to = LOOKUP_SEP.join(lookup.split(LOOKUP_SEP)[:-1] + [to_attr])
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 6436b25bae..3c18fcb4c7 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -1706,8 +1706,7 @@ class Query(BaseExpression):
for alias in self._gen_col_aliases([annotation]):
if isinstance(self.alias_map[alias], Join):
raise FieldError(
- 'Joined field references are not permitted in '
- 'this query'
+ 'Joined field references are not permitted in this query'
)
if summarize:
# Summarize currently means we are doing an aggregate() query
@@ -1734,8 +1733,9 @@ class Query(BaseExpression):
if not allow_joins and len(join_list) > 1:
raise FieldError('Joined field references are not permitted in this query')
if len(targets) > 1:
- raise FieldError("Referencing multicolumn fields with F() objects "
- "isn't supported")
+ raise FieldError(
+ "Referencing multicolumn fields with F() objects isn't supported"
+ )
# Verify that the last lookup in name is a field or a transform:
# transform_function() raises FieldError if not.
transform = join_info.transform_function(targets[0], final_alias)