Skip to content

Commit

Permalink
[flake8] Resolving F8?? errors (apache#3778)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-bodley authored and mistercrunch committed Nov 7, 2017
1 parent 190dd50 commit 53f9edf
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 32 deletions.
2 changes: 1 addition & 1 deletion superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
16 changes: 6 additions & 10 deletions tests/access_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -436,9 +435,6 @@ def test_request_access(self):
'datasource_type={}&'
'datasource_id={}&'
'action={}&')
ROLE_EXTEND_LINK = (
'<a href="/superset/approve?datasource_type={}&datasource_id={}&'
'created_by={}&role_to_extend={}">Extend {} Role</a>')
ROLE_GRANT_LINK = (
'<a href="/superset/approve?datasource_type={}&datasource_id={}&'
'created_by={}&role_to_grant={}">Grant {} Role</a>')
Expand Down
2 changes: 0 additions & 2 deletions tests/celery_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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'})
Expand All @@ -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'):
Expand Down Expand Up @@ -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")
Expand Down
8 changes: 0 additions & 8 deletions tests/db_engine_specs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: <PERFLOG method=compile from=org.apache.hadoop.hive.ql.Driver>
17/02/07 18:26:27 INFO log.PerfLogger: <PERFLOG method=parse from=org.apache.hadoop.hive.ql.Driver>
""".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
Expand Down
4 changes: 2 additions & 2 deletions tests/druid_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/viz_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ ignore =
F401
F403
F405
F811
F841
I100
I101
I201
Expand Down

0 comments on commit 53f9edf

Please sign in to comment.