Browse Source

[models/variable_value] lint code

Maxime Alves LIRMM@home 3 years ago
parent
commit
d16554a59f
1 changed files with 3 additions and 8 deletions
  1. 3
    8
      pyheatpump/models/variable_value.py

+ 3
- 8
pyheatpump/models/variable_value.py View File

@@ -1,6 +1,5 @@
1 1
 from pyheatpump.db import DB, RowClass
2 2
 from datetime import datetime
3
-from pprint import pprint
4 3
 
5 4
 from .variable_type import VariableType
6 5
 from pyheatpump.logger import logger_init
@@ -15,11 +14,7 @@ class VariableValue(RowClass):
15 14
     value: int = None
16 15
 
17 16
     def __init__(self, **kwargs):
18
-        logger.debug("""Create VariableValue object with attributes\n
19
-        :type:{}
20
-        :address:{}
21
-        :value:{}""".format(*kwargs.values()))
22
-        if 'type' in kwargs.keys() and type(kwargs['type']) != VariableType:
17
+        if 'type' in kwargs.keys() and isinstance(kwargs['type'], VariableType):
23 18
             kwargs['type'] = VariableType.get(kwargs['type'])
24 19
 
25 20
 
@@ -70,7 +65,7 @@ class VariableValue(RowClass):
70 65
         return self.insert()
71 66
 
72 67
     @staticmethod
73
-    def get(type, address, time=datetime.now()):
68
+    def get(var_type, address, time=datetime.now()):
74 69
         try:
75 70
             row = next(DB.sql(
76 71
             """SELECT * FROM var_value
@@ -80,7 +75,7 @@ class VariableValue(RowClass):
80 75
                 AND time <= :time
81 76
             ORDER BY time DESC
82 77
             LIMIT 1""", {
83
-                'type':str(type), 'address':address, 'time':int(time.strftime('%s'))+1
78
+                'type':str(var_type), 'address':address, 'time':int(time.strftime('%s'))+1
84 79
             }))
85 80
             return VariableValue(**dict(row))
86 81
         except StopIteration as e:

Loading…
Cancel
Save