superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] branch master updated: [flake8] Resolving F5?? errors (#3846)
Date Sun, 12 Nov 2017 19:09:25 GMT
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 1b4f128  [flake8] Resolving F5?? errors (#3846)
1b4f128 is described below

commit 1b4f128f55e4eb0944a0caa255fa4a90b7db4716
Author: John Bodley <4567245+john-bodley@users.noreply.github.com>
AuthorDate: Sun Nov 12 11:09:22 2017 -0800

    [flake8] Resolving F5?? errors (#3846)
---
 superset/config.py            |  4 +++-
 superset/models/core.py       | 20 ++++++++++++++------
 superset/sql_lab.py           |  5 ++++-
 superset/views/core.py        | 16 ++++++++++------
 tests/celery_tests.py         |  3 ++-
 tests/core_tests.py           | 16 ++++++++++++----
 tests/db_engine_specs_test.py | 12 ++++++------
 tox.ini                       |  1 -
 8 files changed, 51 insertions(+), 26 deletions(-)

diff --git a/superset/config.py b/superset/config.py
index 89b024c..95ee3b0 100644
--- a/superset/config.py
+++ b/superset/config.py
@@ -348,7 +348,9 @@ try:
         print('Loaded your LOCAL configuration at [{}]'.format(
             os.environ[CONFIG_PATH_ENV_VAR]))
         module = sys.modules[__name__]
-        override_conf = imp.load_source('superset_config', os.environ[CONFIG_PATH_ENV_VAR])
+        override_conf = imp.load_source(
+            'superset_config',
+            os.environ[CONFIG_PATH_ENV_VAR])
         for key in dir(override_conf):
             if key.isupper():
                 setattr(module, key, getattr(override_conf, key))
diff --git a/superset/models/core.py b/superset/models/core.py
index e067da4..130f63e 100644
--- a/superset/models/core.py
+++ b/superset/models/core.py
@@ -612,7 +612,10 @@ class Database(Model, AuditMixinNullable):
             effective_username = url.username
             if user_name:
                 effective_username = user_name
-            elif hasattr(g, 'user') and hasattr(g.user, 'username') and g.user.username is
not None:
+            elif (
+                hasattr(g, 'user') and hasattr(g.user, 'username') and
+                g.user.username is not None
+            ):
                 effective_username = g.user.username
         return effective_username
 
@@ -622,8 +625,12 @@ class Database(Model, AuditMixinNullable):
         url = self.db_engine_spec.adjust_database_uri(url, schema)
         effective_username = self.get_effective_user(url, user_name)
         # If using MySQL or Presto for example, will set url.username
-        # If using Hive, will not do anything yet since that relies on a configuration parameter
instead.
-        self.db_engine_spec.modify_url_for_impersonation(url, self.impersonate_user, effective_username)
+        # If using Hive, will not do anything yet since that relies on a
+        # configuration parameter instead.
+        self.db_engine_spec.modify_url_for_impersonation(
+            url,
+            self.impersonate_user,
+            effective_username)
 
         masked_url = self.get_password_masked_url(url)
         logging.info("Database.get_sqla_engine(). Masked URL: {0}".format(masked_url))
@@ -635,9 +642,10 @@ class Database(Model, AuditMixinNullable):
         # If using Hive, this will set hive.server2.proxy.user=$effective_username
         configuration = {}
         configuration.update(
-            self.db_engine_spec.get_configuration_for_impersonation(str(url),
-                                                                    self.impersonate_user,
-                                                                    effective_username))
+            self.db_engine_spec.get_configuration_for_impersonation(
+                str(url),
+                self.impersonate_user,
+                effective_username))
         if configuration:
             params["connect_args"] = {"configuration": configuration}
 
diff --git a/superset/sql_lab.py b/superset/sql_lab.py
index 937f222..ab0f960 100644
--- a/superset/sql_lab.py
+++ b/superset/sql_lab.py
@@ -176,7 +176,10 @@ def execute_sql(
     conn = None
     try:
         engine = database.get_sqla_engine(
-            schema=query.schema, nullpool=not ctask.request.called_directly, user_name=user_name)
+            schema=query.schema,
+            nullpool=not ctask.request.called_directly,
+            user_name=user_name,
+        )
         conn = engine.raw_connection()
         cursor = conn.cursor()
         logging.info("Running query: \n{}".format(executed_sql))
diff --git a/superset/views/core.py b/superset/views/core.py
index 3cbe7a6..c106556 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -238,10 +238,11 @@ class DatabaseView(SupersetModelView, DeleteMixin):  # noqa
             "(http://docs.sqlalchemy.org/en/rel_1_0/core/metadata.html"
             "#sqlalchemy.schema.MetaData) call. ", True),
         'impersonate_user': _(
-            "If Presto, all the queries in SQL Lab are going to be executed as the currently
logged on user "
-            "who must have permission to run them.<br/>"
-            "If Hive and hive.server2.enable.doAs is enabled, will run the queries as service
account, "
-            "but impersonate the currently logged on user via hive.server2.proxy.user property."),
+            "If Presto, all the queries in SQL Lab are going to be executed as the "
+            "currently logged on user who must have permission to run them.<br/>"
+            "If Hive and hive.server2.enable.doAs is enabled, will run the queries as "
+            "service account, but impersonate the currently logged on user "
+            "via hive.server2.proxy.user property."),
     }
     label_columns = {
         'expose_in_sqllab': _("Expose in SQL Lab"),
@@ -1102,7 +1103,9 @@ class Superset(BaseSupersetView):
         action = request.args.get('action')
 
         if action == 'overwrite' and not slice_overwrite_perm:
-            return json_error_response("You don't have the rights to alter this slice", status=400)
+            return json_error_response(
+                "You don't have the rights to alter this slice",
+                status=400)
 
         if action in ('saveas', 'overwrite'):
             return self.save_or_overwrite_slice(
@@ -1462,7 +1465,8 @@ class Superset(BaseSupersetView):
 
             if database and uri:
                 url = make_url(uri)
-                db_engine = models.Database.get_db_engine_spec_for_backend(url.get_backend_name())
+                db_engine = models.Database.get_db_engine_spec_for_backend(
+                    url.get_backend_name())
                 db_engine.patch()
 
                 masked_url = database.get_password_masked_url_from_uri(uri)
diff --git a/tests/celery_tests.py b/tests/celery_tests.py
index a825b4d..b171b52 100644
--- a/tests/celery_tests.py
+++ b/tests/celery_tests.py
@@ -27,7 +27,8 @@ BASE_DIR = app.config.get('BASE_DIR')
 class CeleryConfig(object):
     BROKER_URL = 'sqla+sqlite:///' + app.config.get('SQL_CELERY_DB_FILE_PATH')
     CELERY_IMPORTS = ('superset.sql_lab', )
-    CELERY_RESULT_BACKEND = 'db+sqlite:///' + app.config.get('SQL_CELERY_RESULTS_DB_FILE_PATH')
+    CELERY_RESULT_BACKEND = (
+        'db+sqlite:///' + app.config.get('SQL_CELERY_RESULTS_DB_FILE_PATH'))
     CELERY_ANNOTATIONS = {'sql_lab.add': {'rate_limit': '10/s'}}
     CONCURRENCY = 1
 
diff --git a/tests/core_tests.py b/tests/core_tests.py
index 04f4746..44da324 100644
--- a/tests/core_tests.py
+++ b/tests/core_tests.py
@@ -283,7 +283,10 @@ class CoreTests(SupersetTestCase):
             'name': 'main',
             'impersonate_user': False,
         })
-        response = self.client.post('/superset/testconn', data=data, content_type='application/json')
+        response = self.client.post(
+            '/superset/testconn',
+            data=data,
+            content_type='application/json')
         assert response.status_code == 200
         assert response.headers['Content-Type'] == 'application/json'
 
@@ -293,7 +296,10 @@ class CoreTests(SupersetTestCase):
             'name': 'main',
             'impersonate_user': False,
         })
-        response = self.client.post('/superset/testconn', data=data, content_type='application/json')
+        response = self.client.post(
+            '/superset/testconn',
+            data=data,
+            content_type='application/json')
         assert response.status_code == 200
         assert response.headers['Content-Type'] == 'application/json'
 
@@ -311,7 +317,8 @@ class CoreTests(SupersetTestCase):
             assert conn.password != conn_pre.password
 
     def test_databaseview_edit(self, username='admin'):
-        # validate that sending a password-masked uri does not over-write the decrypted uri
+        # validate that sending a password-masked uri does not over-write the decrypted
+        # uri
         self.login(username=username)
         database = self.get_main_database(db.session)
         sqlalchemy_uri_decrypted = database.sqlalchemy_uri_decrypted
@@ -740,7 +747,8 @@ class CoreTests(SupersetTestCase):
         self.assertNotIn('message', data)
         data = self.get_json_resp('/superset/fave_dashboards/{}/'.format(userid))
         self.assertNotIn('message', data)
-        data = self.get_json_resp('/superset/fave_dashboards_by_username/{}/'.format(username))
+        data = self.get_json_resp(
+            '/superset/fave_dashboards_by_username/{}/'.format(username))
         self.assertNotIn('message', data)
 
     def test_slice_id_is_always_logged_correctly_on_web_request(self):
diff --git a/tests/db_engine_specs_test.py b/tests/db_engine_specs_test.py
index e348b90..a2310d1 100644
--- a/tests/db_engine_specs_test.py
+++ b/tests/db_engine_specs_test.py
@@ -13,7 +13,7 @@ class DbEngineSpecsTestCase(unittest.TestCase):
         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')
+        """.split('\n')  # noqa ignore: E501
         self.assertEquals(
             0, HiveEngineSpec.progress(log))
 
@@ -35,7 +35,7 @@ class DbEngineSpecsTestCase(unittest.TestCase):
             17/02/07 19:15:55 INFO ql.Driver: Total jobs = 2
             17/02/07 19:15:55 INFO ql.Driver: Launching Job 1 out of 2
             17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 0%, 
reduce = 0%
-        """.split('\n')
+        """.split('\n')  # noqa ignore: E501
         self.assertEquals(0, HiveEngineSpec.progress(log))
 
     def test_job_1_launched_stage_1_map_40_progress(self):
@@ -44,7 +44,7 @@ class DbEngineSpecsTestCase(unittest.TestCase):
             17/02/07 19:15:55 INFO ql.Driver: Launching Job 1 out of 2
             17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 0%, 
reduce = 0%
             17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 40%,
 reduce = 0%
-        """.split('\n')
+        """.split('\n')  # noqa ignore: E501
         self.assertEquals(10, HiveEngineSpec.progress(log))
 
     def test_job_1_launched_stage_1_map_80_reduce_40_progress(self):
@@ -54,7 +54,7 @@ class DbEngineSpecsTestCase(unittest.TestCase):
             17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 0%, 
reduce = 0%
             17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 40%,
 reduce = 0%
             17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 80%,
 reduce = 40%
-        """.split('\n')
+        """.split('\n')  # noqa ignore: E501
         self.assertEquals(30, HiveEngineSpec.progress(log))
 
     def test_job_1_launched_stage_2_stages_progress(self):
@@ -66,7 +66,7 @@ class DbEngineSpecsTestCase(unittest.TestCase):
             17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 80%,
 reduce = 40%
             17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-2 map = 0%, 
reduce = 0%
             17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 100%,
 reduce = 0%
-        """.split('\n')
+        """.split('\n')  # noqa ignore: E501
         self.assertEquals(12, HiveEngineSpec.progress(log))
 
     def test_job_2_launched_stage_2_stages_progress(self):
@@ -77,5 +77,5 @@ class DbEngineSpecsTestCase(unittest.TestCase):
             17/02/07 19:15:55 INFO ql.Driver: Launching Job 2 out of 2
             17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 0%, 
reduce = 0%
             17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 40%,
 reduce = 0%
-        """.split('\n')
+        """.split('\n')  # noqa ignore: E501
         self.assertEquals(60, HiveEngineSpec.progress(log))
diff --git a/tox.ini b/tox.ini
index fc926b9..177858d 100644
--- a/tox.ini
+++ b/tox.ini
@@ -17,7 +17,6 @@ exclude =
     superset/migrations
     superset/templates
 ignore =
-    E501
     Q000
     Q001
 import-order-style = google

-- 
To stop receiving notification emails like this one, please contact
['"commits@superset.apache.org" <commits@superset.apache.org>'].

Mime
View raw message