From a500e309c56af8188218e9f283d391578fca2355 Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Fri, 30 Apr 2021 12:06:01 +0200 Subject: [PATCH] code clean up --- .pre-commit-config.yaml | 4 +++- .prospector.yaml | 3 +++ .pylintrc | 20 -------------------- server.py | 2 +- trip.py | 5 ++--- web/views.py | 16 ++++++++-------- 6 files changed, 17 insertions(+), 33 deletions(-) delete mode 100644 .pylintrc diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bfeb6c2..2ae7776 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/.prospector.yaml b/.prospector.yaml index 56712b4..5e0b84a 100644 --- a/.prospector.yaml +++ b/.prospector.yaml @@ -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 + diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index 8ea5eb8..0000000 --- a/.pylintrc +++ /dev/null @@ -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 diff --git a/server.py b/server.py index 2f5a164..b9e28cb 100755 --- a/server.py +++ b/server.py @@ -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+") diff --git a/trip.py b/trip.py index 09a3b92..9960abe 100644 --- a/trip.py +++ b/trip.py @@ -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() diff --git a/web/views.py b/web/views.py index 3965870..ac330da 100644 --- a/web/views.py +++ b/web/views.py @@ -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") ])])