Fixed #28906 -- Removed unnecessary bool() calls.
This commit is contained in:
parent
02d9419fe3
commit
2b81faab25
|
@ -142,7 +142,7 @@ class SessionBase:
|
||||||
def is_empty(self):
|
def is_empty(self):
|
||||||
"Return True when there is no session_key and the session is empty."
|
"Return True when there is no session_key and the session is empty."
|
||||||
try:
|
try:
|
||||||
return not bool(self._session_key) and not self._session_cache
|
return not self._session_key and not self._session_cache
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ class RegexValidator:
|
||||||
Validate that the input contains (or does *not* contain, if
|
Validate that the input contains (or does *not* contain, if
|
||||||
inverse_match is True) a match for the regular expression.
|
inverse_match is True) a match for the regular expression.
|
||||||
"""
|
"""
|
||||||
regex_matches = bool(self.regex.search(str(value)))
|
regex_matches = self.regex.search(str(value))
|
||||||
invalid_input = regex_matches if self.inverse_match else not regex_matches
|
invalid_input = regex_matches if self.inverse_match else not regex_matches
|
||||||
if invalid_input:
|
if invalid_input:
|
||||||
raise ValidationError(self.message, code=self.code)
|
raise ValidationError(self.message, code=self.code)
|
||||||
|
|
|
@ -1215,12 +1215,10 @@ class SQLInsertCompiler(SQLCompiler):
|
||||||
qn = self.connection.ops.quote_name
|
qn = self.connection.ops.quote_name
|
||||||
opts = self.query.get_meta()
|
opts = self.query.get_meta()
|
||||||
result = ['INSERT INTO %s' % qn(opts.db_table)]
|
result = ['INSERT INTO %s' % qn(opts.db_table)]
|
||||||
|
fields = self.query.fields or [opts.pk]
|
||||||
has_fields = bool(self.query.fields)
|
|
||||||
fields = self.query.fields if has_fields else [opts.pk]
|
|
||||||
result.append('(%s)' % ', '.join(qn(f.column) for f in fields))
|
result.append('(%s)' % ', '.join(qn(f.column) for f in fields))
|
||||||
|
|
||||||
if has_fields:
|
if self.query.fields:
|
||||||
value_rows = [
|
value_rows = [
|
||||||
[self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields]
|
[self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields]
|
||||||
for obj in self.query.objs
|
for obj in self.query.objs
|
||||||
|
|
|
@ -139,7 +139,7 @@ class BaseForm:
|
||||||
if self._errors is None:
|
if self._errors is None:
|
||||||
is_valid = "Unknown"
|
is_valid = "Unknown"
|
||||||
else:
|
else:
|
||||||
is_valid = self.is_bound and not bool(self._errors)
|
is_valid = self.is_bound and not self._errors
|
||||||
return '<%(cls)s bound=%(bound)s, valid=%(valid)s, fields=(%(fields)s)>' % {
|
return '<%(cls)s bound=%(bound)s, valid=%(valid)s, fields=(%(fields)s)>' % {
|
||||||
'cls': self.__class__.__name__,
|
'cls': self.__class__.__name__,
|
||||||
'bound': self.is_bound,
|
'bound': self.is_bound,
|
||||||
|
|
|
@ -681,7 +681,7 @@ class Select(ChoiceWidget):
|
||||||
def _choice_has_empty_value(choice):
|
def _choice_has_empty_value(choice):
|
||||||
"""Return True if the choice's value is empty string or None."""
|
"""Return True if the choice's value is empty string or None."""
|
||||||
value, _ = choice
|
value, _ = choice
|
||||||
return (isinstance(value, str) and not bool(value)) or value is None
|
return (isinstance(value, str) and not value) or value is None
|
||||||
|
|
||||||
def use_required_attribute(self, initial):
|
def use_required_attribute(self, initial):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -20,7 +20,7 @@ class BaseEngine:
|
||||||
params = params.copy()
|
params = params.copy()
|
||||||
self.name = params.pop('NAME')
|
self.name = params.pop('NAME')
|
||||||
self.dirs = list(params.pop('DIRS'))
|
self.dirs = list(params.pop('DIRS'))
|
||||||
self.app_dirs = bool(params.pop('APP_DIRS'))
|
self.app_dirs = params.pop('APP_DIRS')
|
||||||
if params:
|
if params:
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
"Unknown parameters: {}".format(", ".join(params)))
|
"Unknown parameters: {}".format(", ".join(params)))
|
||||||
|
|
|
@ -324,7 +324,6 @@ def _urlsplit(url, scheme='', allow_fragments=True):
|
||||||
Note that we don't break the components up in smaller bits
|
Note that we don't break the components up in smaller bits
|
||||||
(e.g. netloc is a single string) and we don't expand % escapes."""
|
(e.g. netloc is a single string) and we don't expand % escapes."""
|
||||||
url, scheme, _coerce_result = _coerce_args(url, scheme)
|
url, scheme, _coerce_result = _coerce_args(url, scheme)
|
||||||
allow_fragments = bool(allow_fragments)
|
|
||||||
netloc = query = fragment = ''
|
netloc = query = fragment = ''
|
||||||
i = url.find(':')
|
i = url.find(':')
|
||||||
if i > 0:
|
if i > 0:
|
||||||
|
|
Loading…
Reference in New Issue