Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cleanup] remove six dependency #6091

Merged
merged 1 commit into from
Oct 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def get_git_sha():
'pyyaml>=3.11',
'requests',
'simplejson>=3.15.0',
'six',
'sqlalchemy',
'sqlalchemy-utils',
'sqlparse',
Expand Down
3 changes: 1 addition & 2 deletions superset/connectors/druid/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
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,
Expand Down Expand Up @@ -775,7 +774,7 @@ def granularity(period_name, timezone=None, origin=None):
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'):
Expand Down
5 changes: 2 additions & 3 deletions superset/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
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,
Expand Down Expand Up @@ -777,7 +776,7 @@ def get_quoter(self):
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):
Expand Down Expand Up @@ -814,7 +813,7 @@ def needs_conversion(df_series):
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},
Expand Down
5 changes: 2 additions & 3 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import re
import time
import traceback
from urllib import parse

from flask import (
flash, g, Markup, redirect, render_template, request, Response, url_for,
Expand All @@ -24,8 +25,6 @@
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
Expand Down Expand Up @@ -373,7 +372,7 @@ def form_post(self, form):
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')
Expand Down
30 changes: 15 additions & 15 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
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
Expand All @@ -34,8 +36,6 @@
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
Expand Down Expand Up @@ -120,7 +120,7 @@ def process_metrics(self):
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):
Expand All @@ -139,7 +139,7 @@ def handle_js_int_overflow(data):
# 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):
Expand Down Expand Up @@ -789,7 +789,7 @@ def get_data(self, df):
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
}

Expand Down Expand Up @@ -1089,19 +1089,19 @@ def to_series(self, df, classed='', title_suffix=''):
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
len(self.metric_labels) == 1):
# 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,)
Expand Down Expand Up @@ -1526,18 +1526,18 @@ def get_data(self, df):
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,
Expand Down Expand Up @@ -1753,7 +1753,7 @@ def get_data(self, df):
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'])

Expand Down Expand Up @@ -2509,7 +2509,7 @@ def get_data(self, df):
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',
Expand Down
3 changes: 1 addition & 2 deletions tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
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
Expand Down Expand Up @@ -650,7 +649,7 @@ def test_comments_in_sqlatable_query(self):
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):
Expand Down
5 changes: 1 addition & 4 deletions tests/db_engine_specs_test.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -98,8 +96,7 @@ def test_hive_error_msg(self):

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, '
Expand Down