Skip to content

Commit 539cbf2

Browse files
committed
Chore: Format code using black and isort
1 parent 5d61163 commit 539cbf2

File tree

6 files changed

+20
-17
lines changed

6 files changed

+20
-17
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ test-coverage: install-tests
5353
# Formatting
5454
# ----------
5555
format: install-releasetools
56-
$(isort) .
56+
$(isort) grafana_wtf test
5757
$(black) .
5858

5959

grafana_wtf/commands.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010

1111
from grafana_wtf import __appname__, __version__
1212
from grafana_wtf.core import GrafanaWtf
13-
from grafana_wtf.report.data import output_results, DataSearchReport
13+
from grafana_wtf.report.data import DataSearchReport, output_results
14+
from grafana_wtf.report.tabular import (
15+
TabularEditHistoryReport,
16+
TabularSearchReport,
17+
get_table_format,
18+
)
1419
from grafana_wtf.report.textual import TextualSearchReport
15-
from grafana_wtf.report.tabular import TabularSearchReport, get_table_format, TabularEditHistoryReport
1620
from grafana_wtf.util import (
1721
configure_http_logging,
1822
filter_with_sql,
@@ -225,7 +229,6 @@ def run():
225229
output_format = options["format"]
226230

227231
if options.find or options.replace:
228-
229232
if options.select_dashboard:
230233
# Restrict scan to list of dashboards.
231234
dashboard_uids = read_list(options.select_dashboard)
@@ -253,7 +256,6 @@ def run():
253256
engine.clear_cache()
254257

255258
if options.log:
256-
257259
# Sanity checks.
258260
if output_format.startswith("tab") and options.sql:
259261
raise DocoptExit(
@@ -294,7 +296,6 @@ def run():
294296
output_results(output_format, entries)
295297

296298
if options.explore and options.datasources:
297-
298299
results = engine.explore_datasources()
299300

300301
unused_count = len(results["unused"])

grafana_wtf/report/data.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ def output_results(output_format: str, results: List):
1515

1616

1717
def serialize_results(output_format: str, results: List):
18-
1918
if output_format == "json":
2019
output = json.dumps(results, indent=4)
2120

grafana_wtf/report/tabular.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ def get_datasources(self, item):
8181

8282

8383
class TabularEditHistoryReport:
84-
8584
def __init__(self, data):
8685
self.data = data
8786

grafana_wtf/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,9 @@ def filter_with_sql(data: trecord, view_name: str, expression: str) -> trecord:
196196
:param view_name: View name the data is registered at, when querying per SQL.
197197
:return:
198198
"""
199-
import pandas as pd
200199
import duckdb
200+
import pandas as pd
201+
201202
df = pd.DataFrame.from_records(data)
202203
duckdb.register(view_name, df)
203204
results = duckdb.sql(expression)

tests/test_commands.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ def test_log_empty(docker_grafana, capsys, caplog):
233233

234234

235235
def test_log_all(ldi_resources, capsys, caplog):
236-
237236
# Only provision specific dashboard(s).
238237
ldi_resources(dashboards=["tests/grafana/dashboards/ldi-v27.json", "tests/grafana/dashboards/ldi-v33.json"])
239238

@@ -244,7 +243,7 @@ def test_log_all(ldi_resources, capsys, caplog):
244243
captured = capsys.readouterr()
245244

246245
# Verify output.
247-
assert 'Aggregating edit history for multiple Grafana dashboards' in caplog.text
246+
assert "Aggregating edit history for multiple Grafana dashboards" in caplog.text
248247
history = json.loads(captured.out)
249248
assert len(history) == 3
250249

@@ -324,13 +323,15 @@ def test_log_filter_sql(ldi_resources, capsys, caplog):
324323
ldi_resources(dashboards=["tests/grafana/dashboards/ldi-v27.json", "tests/grafana/dashboards/ldi-v33.json"])
325324

326325
# Run command and capture output.
327-
set_command("""log --format=yaml --sql='
326+
set_command(
327+
"""log --format=yaml --sql='
328328
SELECT url
329329
FROM dashboard_versions
330330
GROUP BY uid, url
331331
HAVING COUNT(version)=1
332332
'
333-
""")
333+
"""
334+
)
334335
with caplog.at_level(logging.DEBUG):
335336
grafana_wtf.commands.run()
336337
captured = capsys.readouterr()
@@ -488,10 +489,12 @@ def test_explore_dashboards_data_details(ldi_resources, capsys, caplog):
488489
assert dashboard.details.targets[0]._panel.type == "graph"
489490
assert dashboard.details.targets[0]._panel.datasource.type == "influxdb"
490491
assert dashboard.details.targets[0]._panel.datasource.uid == "PDF2762CDFF14A314"
491-
assert dashboard.details.targets[0].fields == [{'func': 'mean', 'name': 'P1'}]
492-
assert dashboard.details.templating[0].query == \
493-
"SELECT osm_country_code AS __value, country_and_countrycode AS __text " \
494-
"FROM ldi_network ORDER BY osm_country_code"
492+
assert dashboard.details.targets[0].fields == [{"func": "mean", "name": "P1"}]
493+
assert (
494+
dashboard.details.templating[0].query
495+
== "SELECT osm_country_code AS __value, country_and_countrycode AS __text "
496+
"FROM ldi_network ORDER BY osm_country_code"
497+
)
495498

496499

497500
def test_explore_dashboards_empty_annotations(grafana_version, create_datasource, create_dashboard, capsys, caplog):

0 commit comments

Comments
 (0)