changeset fd7f76efc705 in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset;node=fd7f76efc705
description:
        Remove "is" with literal

        It generates a warning on Python 3.8

        issue8866
        review274601002
diffstat:

 tryton/common/domain_parser.py               |  5 ++---
 tryton/gui/window/view_form/screen/screen.py |  6 ++++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diffs (40 lines):

diff -r c460d5163a30 -r fd7f76efc705 tryton/common/domain_parser.py
--- a/tryton/common/domain_parser.py    Mon Jan 20 11:31:16 2020 +0100
+++ b/tryton/common/domain_parser.py    Mon Jan 20 22:22:16 2020 +0100
@@ -301,14 +301,13 @@
 
     def format_integer():
         factor = float(field.get('factor', 1))
-        if value or value is 0 or isinstance(value, float):
+        if value or isinstance(value, (int, float)):
             return str(int(value * factor))
         return ''
 
     def format_float():
         if (not value
-                and value is not 0
-                and not isinstance(value, (float, Decimal))):
+                and not isinstance(value, (int, float, Decimal))):
             return ''
         if isinstance(value, Decimal):
             cast = Decimal
diff -r c460d5163a30 -r fd7f76efc705 
tryton/gui/window/view_form/screen/screen.py
--- a/tryton/gui/window/view_form/screen/screen.py      Mon Jan 20 11:31:16 
2020 +0100
+++ b/tryton/gui/window/view_form/screen/screen.py      Mon Jan 20 22:22:16 
2020 +0100
@@ -648,12 +648,14 @@
         path = self.current_record.get_path(self.group)
         if self.current_view.view_type == 'tree':
             # False value must be not saved
-            saved = all((x is 0 or x > 0 for x in self.group.save()))
+            saved = all((
+                    x is not False and x >= 0
+                    for x in self.group.save()))
             record_id = self.current_record.id if self.current_record else None
         elif self.current_record.validate(fields):
             record_id = self.current_record.save(force_reload=True)
             # False value must be not saved
-            saved = record_id is 0 or record_id > 0
+            saved = record_id is not False and record_id >= 0
         else:
             self.set_cursor()
             self.current_view.display()

Reply via email to