changeset daa8529c51a7 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=daa8529c51a7
description:
Avoid instantiate set
issue10660
review342911003
diffstat:
trytond/model/fields/char.py | 2 +-
trytond/model/fields/field.py | 16 ++++++++--------
trytond/model/fields/float.py | 2 +-
trytond/model/fields/reference.py | 2 +-
trytond/model/fields/selection.py | 2 +-
trytond/model/modelsql.py | 10 +++++-----
trytond/model/modelstorage.py | 2 +-
7 files changed, 18 insertions(+), 18 deletions(-)
diffs (175 lines):
diff -r df00526a82b2 -r daa8529c51a7 trytond/model/fields/char.py
--- a/trytond/model/fields/char.py Thu Sep 02 23:19:36 2021 +0200
+++ b/trytond/model/fields/char.py Thu Sep 02 23:56:13 2021 +0200
@@ -39,7 +39,7 @@
if autocomplete:
warnings.warn('autocomplete argument is deprecated, use the '
'depends decorator', DeprecationWarning, stacklevel=2)
- self.autocomplete |= set(autocomplete)
+ self.autocomplete.update(autocomplete)
self.translate = translate
self.__size = None
self.size = size
diff -r df00526a82b2 -r daa8529c51a7 trytond/model/fields/field.py
--- a/trytond/model/fields/field.py Thu Sep 02 23:19:36 2021 +0200
+++ b/trytond/model/fields/field.py Thu Sep 02 23:56:13 2021 +0200
@@ -38,7 +38,7 @@
and arg[1] in OPERATORS)
or (
isinstance(arg[1], PYSON)
- and arg[1].types() == set([str]))))):
+ and arg[1].types() == {str})))):
pass
elif isinstance(arg, list):
if not test_domain(arg):
@@ -57,7 +57,7 @@
assert isinstance(value[state], (bool, PYSON)), \
'values of states must be PYSON'
if hasattr(value[state], 'types'):
- assert value[state].types() == set([bool]), \
+ assert value[state].types() == {bool}, \
'values of states must return boolean'
@@ -73,7 +73,7 @@
if value is not None:
assert isinstance(value, (int, PYSON)), 'size must be PYSON'
if hasattr(value, 'types'):
- assert value.types() == set([int]), \
+ assert value.types() == {int}, \
'size must return integer'
@@ -81,7 +81,7 @@
if value is not None:
assert isinstance(value, (list, PYSON)), 'search_order must be PYSON'
if hasattr(value, 'types'):
- assert value.types() == set([list]), 'search_order must be PYSON'
+ assert value.types() == {list}, 'search_order must be PYSON'
def _set_value(record, field):
@@ -108,12 +108,12 @@
def decorator(func):
depends = getattr(func, 'depends', set())
- depends |= set(fields)
+ depends.update(fields)
setattr(func, 'depends', depends)
if methods:
depend_methods = getattr(func, 'depend_methods', set())
- depend_methods |= set(methods)
+ depend_methods.update(methods)
setattr(func, 'depend_methods', depend_methods)
@wraps(func)
@@ -267,13 +267,13 @@
warnings.warn('on_change argument is deprecated, '
'use the depends decorator',
DeprecationWarning, stacklevel=3)
- self.on_change |= set(on_change)
+ self.on_change.update(on_change)
self.on_change_with = set()
if on_change_with:
warnings.warn('on_change_with argument is deprecated, '
'use the depends decorator',
DeprecationWarning, stacklevel=3)
- self.on_change_with |= set(on_change_with)
+ self.on_change_with.update(on_change_with)
self.__depends = None
self.depends = depends or []
self.__context = None
diff -r df00526a82b2 -r daa8529c51a7 trytond/model/fields/float.py
--- a/trytond/model/fields/float.py Thu Sep 02 23:19:36 2021 +0200
+++ b/trytond/model/fields/float.py Thu Sep 02 23:56:13 2021 +0200
@@ -13,7 +13,7 @@
assert isinstance(i, (int, PYSON)), \
'digits must be tuple of integers or PYSON'
if isinstance(i, PYSON):
- assert i.types().issubset(set([int, int])), \
+ assert i.types() == {int}, \
'PYSON digits must return an integer'
diff -r df00526a82b2 -r daa8529c51a7 trytond/model/fields/reference.py
--- a/trytond/model/fields/reference.py Thu Sep 02 23:19:36 2021 +0200
+++ b/trytond/model/fields/reference.py Thu Sep 02 23:56:13 2021 +0200
@@ -54,7 +54,7 @@
warnings.warn('selection_change_with argument is deprecated, '
'use the depends decorator',
DeprecationWarning, stacklevel=2)
- self.selection_change_with |= set(selection_change_with)
+ self.selection_change_with.update(selection_change_with)
self.sort = sort
self.translate_selection = translate
self.help_selection = help_selection
diff -r df00526a82b2 -r daa8529c51a7 trytond/model/fields/selection.py
--- a/trytond/model/fields/selection.py Thu Sep 02 23:19:36 2021 +0200
+++ b/trytond/model/fields/selection.py Thu Sep 02 23:56:13 2021 +0200
@@ -103,7 +103,7 @@
warnings.warn('selection_change_with argument is deprecated, '
'use the depends decorator',
DeprecationWarning, stacklevel=2)
- self.selection_change_with |= set(selection_change_with)
+ self.selection_change_with.update(selection_change_with)
self.sort = sort
self.translate_selection = translate
self.help_selection = help_selection
diff -r df00526a82b2 -r daa8529c51a7 trytond/model/modelsql.py
--- a/trytond/model/modelsql.py Thu Sep 02 23:19:36 2021 +0200
+++ b/trytond/model/modelsql.py Thu Sep 02 23:56:13 2021 +0200
@@ -570,7 +570,7 @@
'write_uid', 'write_date', 'id'):
if key in values:
del values[key]
- modified_fields |= set(values.keys())
+ modified_fields |= values.keys()
# Get default values
values_schema = tuple(sorted(values))
@@ -710,7 +710,7 @@
extra_fields.update(fields.get_eval_fields(field.context))
extra_fields.discard('id')
all_fields = (
- set(fields_names) | set(fields_related.keys()) | extra_fields)
+ set(fields_names) | fields_related.keys() | extra_fields)
result = []
table = cls.__table__()
@@ -906,7 +906,7 @@
row[key] = None
to_del = set()
- for fname in set(fields_related.keys()) | extra_fields:
+ for fname in fields_related.keys() | extra_fields:
if fname not in fields_names:
to_del.add(fname)
if fname not in cls._fields:
@@ -1029,12 +1029,12 @@
if hasattr(field, 'set'):
fields_to_set.setdefault(fname, []).extend((ids, value))
- mptt_fields = cls._mptt_fields & set(values)
+ mptt_fields = cls._mptt_fields & values.keys()
if mptt_fields:
cls._update_mptt(
list(sorted(mptt_fields)), repeat(ids, len(mptt_fields)),
values)
- all_field_names |= set(values)
+ all_field_names |= values.keys()
for fname in sorted(fields_to_set, key=cls.index_set_field):
fargs = fields_to_set[fname]
diff -r df00526a82b2 -r daa8529c51a7 trytond/model/modelstorage.py
--- a/trytond/model/modelstorage.py Thu Sep 02 23:19:36 2021 +0200
+++ b/trytond/model/modelstorage.py Thu Sep 02 23:56:13 2021 +0200
@@ -166,7 +166,7 @@
ModelAccess.check(cls.__name__, 'create')
- all_fields = list(set(chain(*(iter(v.keys()) for v in vlist))))
+ all_fields = list(set().union(*vlist))
ModelFieldAccess.check(cls.__name__, all_fields, 'write')
# Increase transaction counter