code clean up

This commit is contained in:
Florian Bezannier
2021-04-30 12:06:01 +02:00
parent 9228886be7
commit a500e309c5
6 changed files with 17 additions and 33 deletions
+3 -1
View File
@@ -1,6 +1,8 @@
default_language_version:
python: python3.6
repos:
- repo: https://github.com/PyCQA/prospector
rev: 1.3.1 # The version of Prospector to use, at least 1.1.7
hooks:
- id: prospector
language: python
language: system
+3
View File
@@ -1,4 +1,6 @@
doc-warnings: false
use: flask
max-line-length: 120
ignore-paths:
- psa_connectedcar
pep8:
@@ -16,3 +18,4 @@ pylint:
- W0603
- I0011
- W0511
-20
View File
@@ -1,20 +0,0 @@
[MASTER]
disable=
C0114,C0115,C0116,W0603,I0011,W0511
enable=
C0326
[FORMAT]
max-line-length=120
[BASIC]
good-names=i,
j,
k,
ex,
Run,
e,
f,
t,
x,
ip,
s
+1 -1
View File
@@ -42,7 +42,7 @@ def parse_args():
return parser.parse_args()
# flake8: noqa: C901
# noqa: MC0001
if __name__ == "__main__":
if sys.version_info < (3, 6):
raise RuntimeError("This application requires Python 3.6+")
+2 -3
View File
@@ -133,10 +133,9 @@ class Trips(list):
logger.debugv("trip discarded")
return False
# flake8: noqa: C901
@staticmethod
@staticmethod # noqa: MC0001
def get_trips(vehicles_list: Cars) -> Dict[str, "Trips"]:
# pylint: disable=too-many-locals,too-many-statements,too-many-nested-blocks
# pylint: disable=too-many-locals,too-many-statements,too-many-nested-blocks,too-many-branches
conn = Database.get_db()
vehicles = conn.execute(
"SELECT DISTINCT vin FROM position;").fetchall()
+8 -8
View File
@@ -54,7 +54,7 @@ def diff_dashtable(data, data_previous, row_id_name="row_id"):
return changes
def create_callback(): # flake8: noqa: C901
def create_callback(): # noqa: MC0001
global CALLBACK_CREATED
if not CALLBACK_CREATED:
@dash_app.callback(Output('trips_map', 'figure'),
@@ -81,8 +81,8 @@ def create_callback(): # flake8: noqa: C901
consumption = "Average consumption: {:.1f} kWh/100km".format(
float(figures.consumption_df["consumption_km"].mean()))
return figures.trips_map, figures.consumption_fig, figures.consumption_fig_by_speed, \
figures.consumption_graph_by_temp, consumption, figures.table_fig, figures.battery_info, \
figures.battery_table, max_millis, step, marks
figures.consumption_graph_by_temp, consumption, figures.table_fig, figures.battery_info, \
figures.battery_table, max_millis, step, marks
@dash_app.callback(Output(EMPTY_DIV, "children"),
[Input("battery-table", "data_timestamp")],
@@ -91,10 +91,10 @@ def create_callback(): # flake8: noqa: C901
def capture_diffs_in_battery_table(timestamp, data, data_previous): # pylint: disable=unused-variable
if timestamp is None:
raise PreventUpdate
diff_data = diff_dashtable(data, data_previous,"start_at")
diff_data = diff_dashtable(data, data_previous, "start_at")
for changed_line in diff_data:
if changed_line['column_name'] == 'price':
if not Database.set_chargings_price(Database.get_db(),changed_line['start_at'],
if not Database.set_chargings_price(Database.get_db(), changed_line['start_at'],
changed_line['current_value']):
logger.error("Can't find line to update in the database")
return ""
@@ -350,9 +350,9 @@ def serve_layout():
dbc.Tab(label="Map", tab_id="map", children=[maps]),
dbc.Tab(label="Control", tab_id="control", children=dbc.Tabs(id="control-tabs",
children=__get_control_tabs()))],
id="tabs",
active_tab="summary",
persistence=True),
id="tabs",
active_tab="summary",
persistence=True),
html.Div(id=EMPTY_DIV),
html.Div(id=EMPTY_DIV + "1")
])])