superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [incubator-superset] branch master updated: remove six dependency (#6091)
Date Sat, 13 Oct 2018 16:38:52 GMT
This is an automated email from the ASF dual-hosted git repository.

timi 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 047c8b0  remove six dependency (#6091)
047c8b0 is described below

commit 047c8b0943963b2a5757a53a2350395a2589fb5b
Author: timifasubaa <30888507+timifasubaa@users.noreply.github.com>
AuthorDate: Sat Oct 13 09:38:46 2018 -0700

    remove six dependency (#6091)
---
 requirements.txt                    |  1 -
 setup.py                            |  1 -
 superset/connectors/druid/models.py |  3 +--
 superset/models/core.py             |  5 ++---
 superset/views/core.py              |  5 ++---
 superset/viz.py                     | 30 +++++++++++++++---------------
 tests/core_tests.py                 |  3 +--
 tests/db_engine_specs_test.py       |  5 +----
 8 files changed, 22 insertions(+), 31 deletions(-)

diff --git a/requirements.txt b/requirements.txt
index e13aaa9..a21cda9 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -75,7 +75,6 @@ rfc3986==1.1.0            # via tableschema
 s3transfer==0.1.13        # via boto3
 sasl==0.2.1               # via thrift-sasl
 simplejson==3.15.0
-six==1.11.0
 sqlalchemy-utils==0.32.21
 sqlalchemy==1.2.2
 sqlparse==0.2.4
diff --git a/setup.py b/setup.py
index 5816a05..f1c5ab0 100644
--- a/setup.py
+++ b/setup.py
@@ -91,7 +91,6 @@ setup(
         'pyyaml>=3.11',
         'requests',
         'simplejson>=3.15.0',
-        'six',
         'sqlalchemy',
         'sqlalchemy-utils',
         'sqlparse',
diff --git a/superset/connectors/druid/models.py b/superset/connectors/druid/models.py
index e318fc3..d0c2760 100644
--- a/superset/connectors/druid/models.py
+++ b/superset/connectors/druid/models.py
@@ -30,7 +30,6 @@ from pydruid.utils.postaggregator import (
     Const, Field, HyperUniqueCardinality, Postaggregator, Quantile, Quantiles,
 )
 import requests
-from six import string_types
 import sqlalchemy as sa
 from sqlalchemy import (
     Boolean, Column, DateTime, ForeignKey, Integer, String, Text, UniqueConstraint,
@@ -775,7 +774,7 @@ class DruidDatasource(Model, BaseDatasource):
             if period_name in ('week_ending_saturday', 'week_starting_sunday'):
                 # use Sunday as start of the week
                 granularity['origin'] = '2016-01-03T00:00:00'
-        elif not isinstance(period_name, string_types):
+        elif not isinstance(period_name, str):
             granularity['type'] = 'duration'
             granularity['duration'] = period_name
         elif period_name.startswith('P'):
diff --git a/superset/models/core.py b/superset/models/core.py
index 1d82dd6..53eb2e2 100644
--- a/superset/models/core.py
+++ b/superset/models/core.py
@@ -21,7 +21,6 @@ from flask_appbuilder.security.sqla.models import User
 from future.standard_library import install_aliases
 import numpy
 import pandas as pd
-import six
 import sqlalchemy as sqla
 from sqlalchemy import (
     Boolean, Column, create_engine, DateTime, ForeignKey, Integer,
@@ -777,7 +776,7 @@ class Database(Model, AuditMixinNullable, ImportMixin):
         return self.get_dialect().identifier_preparer.quote
 
     def get_df(self, sql, schema):
-        sqls = [six.text_type(s).strip().strip(';') for s in sqlparse.parse(sql)]
+        sqls = [str(s).strip().strip(';') for s in sqlparse.parse(sql)]
         engine = self.get_sqla_engine(schema=schema)
 
         def needs_conversion(df_series):
@@ -814,7 +813,7 @@ class Database(Model, AuditMixinNullable, ImportMixin):
     def compile_sqla_query(self, qry, schema=None):
         engine = self.get_sqla_engine(schema=schema)
 
-        sql = six.text_type(
+        sql = str(
             qry.compile(
                 engine,
                 compile_kwargs={'literal_binds': True},
diff --git a/superset/views/core.py b/superset/views/core.py
index e5bd66f..b07b7d2 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -12,6 +12,7 @@ import os
 import re
 import time
 import traceback
+from urllib import parse
 
 from flask import (
     flash, g, Markup, redirect, render_template, request, Response, url_for,
@@ -24,8 +25,6 @@ from flask_babel import gettext as __
 from flask_babel import lazy_gettext as _
 import pandas as pd
 import simplejson as json
-from six import text_type
-from six.moves.urllib import parse
 import sqlalchemy as sqla
 from sqlalchemy import and_, create_engine, MetaData, or_, update
 from sqlalchemy.engine.url import make_url
@@ -373,7 +372,7 @@ class CsvToDatabaseView(SimpleFormView):
             except OSError:
                 pass
             message = 'Table name {} already exists. Please pick another'.format(
-                form.name.data) if isinstance(e, IntegrityError) else text_type(e)
+                form.name.data) if isinstance(e, IntegrityError) else e
             flash(
                 message,
                 'danger')
diff --git a/superset/viz.py b/superset/viz.py
index 09129b7..b0a30e3 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -13,11 +13,13 @@ from __future__ import unicode_literals
 from collections import defaultdict, OrderedDict
 import copy
 from datetime import datetime, timedelta
+from functools import reduce
 import hashlib
 import inspect
 from itertools import product
 import logging
 import math
+import pickle as pkl
 import re
 import traceback
 import uuid
@@ -34,8 +36,6 @@ from pandas.tseries.frequencies import to_offset
 from past.builtins import basestring
 import polyline
 import simplejson as json
-from six import string_types, text_type
-from six.moves import cPickle as pkl, reduce
 
 from superset import app, cache, get_css_manifest_files, utils
 from superset.exceptions import NullValueException, SpatialException
@@ -120,7 +120,7 @@ class BaseViz(object):
         self.metric_labels = list(self.metric_dict.keys())
 
     def get_metric_label(self, metric):
-        if isinstance(metric, string_types):
+        if isinstance(metric, str):
             return metric
 
         if isinstance(metric, dict):
@@ -139,7 +139,7 @@ class BaseViz(object):
                     # if an int is too big for Java Script to handle
                     # convert it to a string
                     if abs(v) > JS_MAX_INTEGER:
-                        d[k] = text_type(v)
+                        d[k] = str(v)
         return data
 
     def run_extra_queries(self):
@@ -789,7 +789,7 @@ class CalHeatmapViz(BaseViz):
         records = df.to_dict('records')
         for metric in self.metric_labels:
             data[metric] = {
-                text_type(obj[DTTM_ALIAS].value / 10**9): obj.get(metric)
+                str(obj[DTTM_ALIAS].value / 10**9): obj.get(metric)
                 for obj in records
             }
 
@@ -1089,11 +1089,11 @@ class NVD3TimeSeriesViz(NVD3Viz):
             if df[name].dtype.kind not in 'biufc':
                 continue
             if isinstance(name, list):
-                series_title = [text_type(title) for title in name]
+                series_title = [str(title) for title in name]
             elif isinstance(name, tuple):
-                series_title = tuple(text_type(title) for title in name)
+                series_title = tuple(str(title) for title in name)
             else:
-                series_title = text_type(name)
+                series_title = str(name)
             if (
                     isinstance(series_title, (list, tuple)) and
                     len(series_title) > 1 and
@@ -1101,7 +1101,7 @@ class NVD3TimeSeriesViz(NVD3Viz):
                 # Removing metric from series name if only one metric
                 series_title = series_title[1:]
             if title_suffix:
-                if isinstance(series_title, string_types):
+                if isinstance(series_title, str):
                     series_title = (series_title, title_suffix)
                 elif isinstance(series_title, (list, tuple)):
                     series_title = series_title + (title_suffix,)
@@ -1526,18 +1526,18 @@ class DistributionBarViz(DistributionPieViz):
         for name, ys in pt.items():
             if pt[name].dtype.kind not in 'biufc' or name in self.groupby:
                 continue
-            if isinstance(name, string_types):
+            if isinstance(name, str):
                 series_title = name
             else:
                 offset = 0 if len(metrics) > 1 else 1
-                series_title = ', '.join([text_type(s) for s in name[offset:]])
+                series_title = ', '.join([str(s) for s in name[offset:]])
             values = []
             for i, v in ys.items():
                 x = i
                 if isinstance(x, (tuple, list)):
-                    x = ', '.join([text_type(s) for s in x])
+                    x = ', '.join([str(s) for s in x])
                 else:
-                    x = text_type(x)
+                    x = str(x)
                 values.append({
                     'x': x,
                     'y': v,
@@ -1753,7 +1753,7 @@ class WorldMapViz(BaseViz):
         d = df.to_dict(orient='records')
         for row in d:
             country = None
-            if isinstance(row['country'], string_types):
+            if isinstance(row['country'], str):
                 country = countries.get(
                     fd.get('country_fieldtype'), row['country'])
 
@@ -2509,7 +2509,7 @@ class PairedTTestViz(BaseViz):
         series = df.to_dict('series')
         for nameSet in df.columns:
             # If no groups are defined, nameSet will be the metric name
-            hasGroup = not isinstance(nameSet, string_types)
+            hasGroup = not isinstance(nameSet, str)
             Y = series[nameSet]
             d = {
                 'group': nameSet[1:] if hasGroup else 'All',
diff --git a/tests/core_tests.py b/tests/core_tests.py
index 74f790c..768d021 100644
--- a/tests/core_tests.py
+++ b/tests/core_tests.py
@@ -15,7 +15,6 @@ import unittest
 import mock
 import pandas as pd
 import psycopg2
-from six import text_type
 import sqlalchemy as sqla
 
 from superset import dataframe, db, jinja_context, security_manager, sql_lab, utils
@@ -650,7 +649,7 @@ class CoreTests(SupersetTestCase):
         clean_query = "SELECT '/* val 1 */' as c1, '-- val 2' as c2 FROM tbl"
         commented_query = '/* comment 1 */' + clean_query + '-- comment 2'
         table = SqlaTable(sql=commented_query)
-        rendered_query = text_type(table.get_from_clause())
+        rendered_query = str(table.get_from_clause())
         self.assertEqual(clean_query, rendered_query)
 
     def test_slice_payload_no_data(self):
diff --git a/tests/db_engine_specs_test.py b/tests/db_engine_specs_test.py
index cbcb129..c39344e 100644
--- a/tests/db_engine_specs_test.py
+++ b/tests/db_engine_specs_test.py
@@ -1,8 +1,6 @@
 # -*- coding: utf-8 -*-
 import inspect
 
-from six import text_type
-
 from superset import db_engine_specs
 from superset.db_engine_specs import (
     BaseEngineSpec, HiveEngineSpec, MssqlEngineSpec,
@@ -98,8 +96,7 @@ class DbEngineSpecsTestCase(SupersetTestCase):
 
         e = Exception("Some string that doesn't match the regex")
         self.assertEquals(
-            text_type(e),
-            HiveEngineSpec.extract_error_message(e))
+            str(e), HiveEngineSpec.extract_error_message(e))
 
         msg = (
             'errorCode=10001, '


Mime
View raw message