From 53f9edfefba8de9b38ad6fb38dd66dd40add8807 Mon Sep 17 00:00:00 2001
From: John Bodley <4567245+john-bodley@users.noreply.github.com>
Date: Mon, 6 Nov 2017 21:15:36 -0800
Subject: [PATCH] [flake8] Resolving F8?? errors (#3778)
---
superset/views/core.py | 2 +-
tests/access_tests.py | 16 ++++++----------
tests/celery_tests.py | 2 --
tests/core_tests.py | 10 +++++-----
tests/db_engine_specs_test.py | 8 --------
tests/druid_tests.py | 4 ++--
tests/viz_tests.py | 4 ++--
tox.ini | 2 --
8 files changed, 16 insertions(+), 32 deletions(-)
diff --git a/superset/views/core.py b/superset/views/core.py
index 9e1d6ec364923..7c60f86aba7ab 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -2057,7 +2057,7 @@ def stop_query(self):
)
query.status = utils.QueryStatus.STOPPED
db.session.commit()
- except Exception as e:
+ except Exception:
pass
return self.json_response('OK')
diff --git a/tests/access_tests.py b/tests/access_tests.py
index ec1ce7483dcea..8fa1fb53f4ae2 100644
--- a/tests/access_tests.py
+++ b/tests/access_tests.py
@@ -8,7 +8,7 @@
import mock
import unittest
-from superset import db, models, sm, security
+from superset import db, sm, security
from superset.models import core as models
from superset.connectors.connector_registry import ConnectorRegistry
@@ -204,7 +204,7 @@ def test_clean_requests_after_role_extend(self):
access_request1 = create_access_request(
session, 'table', 'random_time_series', TEST_ROLE_1, 'gamma2')
ds_1_id = access_request1.datasource_id
- access_request2 = create_access_request(
+ create_access_request(
session, 'table', 'random_time_series', TEST_ROLE_1, 'gamma')
access_requests = self.get_access_requests('gamma', 'table', ds_1_id)
self.assertTrue(access_requests)
@@ -229,7 +229,7 @@ def test_clean_requests_after_alpha_grant(self):
access_request1 = create_access_request(
session, 'table', 'birth_names', TEST_ROLE_1, 'gamma')
- access_request2 = create_access_request(
+ create_access_request(
session, 'table', 'birth_names', TEST_ROLE_2, 'gamma2')
ds_1_id = access_request1.datasource_id
# gamma becomes alpha
@@ -258,7 +258,7 @@ def test_clean_requests_after_db_grant(self):
gamma_user = sm.find_user(username='gamma')
access_request1 = create_access_request(
session, 'table', 'long_lat', TEST_ROLE_1, 'gamma')
- access_request2 = create_access_request(
+ create_access_request(
session, 'table', 'long_lat', TEST_ROLE_2, 'gamma2')
ds_1_id = access_request1.datasource_id
# gamma gets granted database access
@@ -294,7 +294,7 @@ def test_clean_requests_after_schema_grant(self):
gamma_user = sm.find_user(username='gamma')
access_request1 = create_access_request(
session, 'table', 'wb_health_population', TEST_ROLE_1, 'gamma')
- access_request2 = create_access_request(
+ create_access_request(
session, 'table', 'wb_health_population', TEST_ROLE_2, 'gamma2')
ds_1_id = access_request1.datasource_id
ds = session.query(SqlaTable).filter_by(
@@ -335,9 +335,8 @@ def test_approve(self, mock_send_mime):
access_request1 = create_access_request(
session, 'table', 'unicode_test', TEST_ROLE_NAME, 'gamma')
ds_1_id = access_request1.datasource_id
- resp = self.get_resp(GRANT_ROLE_REQUEST.format(
+ self.get_resp(GRANT_ROLE_REQUEST.format(
'table', ds_1_id, 'gamma', TEST_ROLE_NAME))
-
# Test email content.
self.assertTrue(mock_send_mime.called)
call_args = mock_send_mime.call_args[0]
@@ -436,9 +435,6 @@ def test_request_access(self):
'datasource_type={}&'
'datasource_id={}&'
'action={}&')
- ROLE_EXTEND_LINK = (
- 'Extend {} Role')
ROLE_GRANT_LINK = (
'Grant {} Role')
diff --git a/tests/celery_tests.py b/tests/celery_tests.py
index a47984172787d..ce88cafa0cbeb 100644
--- a/tests/celery_tests.py
+++ b/tests/celery_tests.py
@@ -139,9 +139,7 @@ def run_sql(self, db_id, sql, client_id, cta='false', tmp_table='tmp',
return json.loads(resp.data.decode('utf-8'))
def test_add_limit_to_the_query(self):
- session = db.session
main_db = self.get_main_database(db.session)
- eng = main_db.get_sqla_engine()
select_query = "SELECT * FROM outer_space;"
updated_select_query = main_db.wrap_sql_limit(select_query, 100)
diff --git a/tests/core_tests.py b/tests/core_tests.py
index 3ff43d3459954..7d1b2fd1ca4b1 100644
--- a/tests/core_tests.py
+++ b/tests/core_tests.py
@@ -149,7 +149,7 @@ def test_save_slice(self):
'slice_id': slice_id,
}
# Changing name and save as a new slice
- resp = self.get_resp(
+ self.get_resp(
url.format(
tbl_id,
copy_name,
@@ -170,7 +170,7 @@ def test_save_slice(self):
'slice_id': new_slice_id,
}
# Setting the name back to its original name by overwriting new slice
- resp = self.get_resp(
+ self.get_resp(
url.format(
tbl_id,
new_slice_name,
@@ -353,7 +353,7 @@ def test_kv(self):
try:
resp = self.client.post('/kv/store/', data=dict())
- except Exception as e:
+ except Exception:
self.assertRaises(TypeError)
value = json.dumps({'data': 'this is a test'})
@@ -370,7 +370,7 @@ def test_kv(self):
try:
resp = self.client.get('/kv/10001/')
- except Exception as e:
+ except Exception:
self.assertRaises(TypeError)
def test_save_dash(self, username='admin'):
@@ -456,7 +456,7 @@ def test_save_dash_with_dashboard_title(self, username='admin'):
'dashboard_title': 'new title'
}
url = '/superset/save_dash/{}/'.format(dash.id)
- resp = self.get_resp(url, data=dict(data=json.dumps(data)))
+ self.get_resp(url, data=dict(data=json.dumps(data)))
updatedDash = (
db.session.query(models.Dashboard)
.filter_by(slug="births")
diff --git a/tests/db_engine_specs_test.py b/tests/db_engine_specs_test.py
index a3038132c0a8c..67d5d0d022a52 100644
--- a/tests/db_engine_specs_test.py
+++ b/tests/db_engine_specs_test.py
@@ -17,14 +17,6 @@ def test_0_progress(self):
self.assertEquals(
0, HiveEngineSpec.progress(log))
- def test_0_progress(self):
- log = """
- 17/02/07 18:26:27 INFO log.PerfLogger:
- 17/02/07 18:26:27 INFO log.PerfLogger:
- """.split('\n')
- self.assertEquals(
- 0, HiveEngineSpec.progress(log))
-
def test_number_of_jobs_progress(self):
log = """
17/02/07 19:15:55 INFO ql.Driver: Total jobs = 2
diff --git a/tests/druid_tests.py b/tests/druid_tests.py
index d274691940a5d..c562c8dcf2b1c 100644
--- a/tests/druid_tests.py
+++ b/tests/druid_tests.py
@@ -76,7 +76,7 @@ class DruidTests(SupersetTestCase):
def __init__(self, *args, **kwargs):
super(DruidTests, self).__init__(*args, **kwargs)
- @patch('superset.connectors.druid.models.PyDruid')
+ @patch('superset.connectors.druid.models.PyDruid') # noqa ignore: F811
def test_client(self, PyDruid):
self.login(username='admin')
instance = PyDruid.return_value
@@ -281,7 +281,7 @@ def test_filter_druid_datasource(self):
self.assertIn('datasource_for_gamma', resp)
self.assertNotIn('datasource_not_for_gamma', resp)
- @patch('superset.connectors.druid.models.PyDruid')
+ @patch('superset.connectors.druid.models.PyDruid') # noqa ignore: F811
def test_sync_druid_perm(self, PyDruid):
self.login(username='admin')
instance = PyDruid.return_value
diff --git a/tests/viz_tests.py b/tests/viz_tests.py
index 99111b5c95e05..3e976567b263d 100644
--- a/tests/viz_tests.py
+++ b/tests/viz_tests.py
@@ -73,7 +73,7 @@ def test_get_df_handles_dttm_col(self):
datasource.query = Mock(return_value=results)
test_viz = viz.BaseViz(datasource, form_data)
test_viz.get_fillna_for_columns = Mock(return_value=0)
- result = test_viz.get_df(query_obj)
+ test_viz.get_df(query_obj)
mock_call = df.__setitem__.mock_calls[0]
self.assertEqual(mock_call[1][0], DTTM_ALIAS)
self.assertFalse(mock_call[1][1].empty)
@@ -83,7 +83,7 @@ def test_get_df_handles_dttm_col(self):
self.assertEqual(mock_call[1][1][0].hour, 6)
self.assertEqual(mock_call[1][1].dtype, 'datetime64[ns]')
mock_dttm_col.python_date_format = 'utc'
- result = test_viz.get_df(query_obj)
+ test_viz.get_df(query_obj)
mock_call = df.__setitem__.mock_calls[2]
self.assertEqual(mock_call[1][0], DTTM_ALIAS)
self.assertFalse(mock_call[1][1].empty)
diff --git a/tox.ini b/tox.ini
index fd75723eedeff..f3420a5f2c765 100644
--- a/tox.ini
+++ b/tox.ini
@@ -45,8 +45,6 @@ ignore =
F401
F403
F405
- F811
- F841
I100
I101
I201