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

[flake8] Resolving Q??? errors #3847

Merged
merged 1 commit into from
Nov 14, 2017
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
14 changes: 7 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ def get_git_sha():
s = str(subprocess.check_output(['git', 'rev-parse', 'HEAD']))
return s.strip()
except Exception:
return ""
return ''


GIT_SHA = get_git_sha()
version_info = {
'GIT_SHA': GIT_SHA,
'version': version_string,
}
print("-==-" * 15)
print("VERSION: " + version_string)
print("GIT SHA: " + GIT_SHA)
print("-==-" * 15)
print('-==-' * 15)
print('VERSION: ' + version_string)
print('GIT SHA: ' + GIT_SHA)
print('-==-' * 15)

with open(os.path.join(PACKAGE_DIR, 'version_info.json'), 'w') as version_file:
json.dump(version_info, version_file)
Expand All @@ -36,8 +36,8 @@ def get_git_sha():
setup(
name='superset',
description=(
"A interactive data visualization platform build on SqlAlchemy "
"and druid.io"),
'A interactive data visualization platform build on SqlAlchemy '
'and druid.io'),
version=version_string,
packages=find_packages(),
include_package_data=True,
Expand Down
14 changes: 7 additions & 7 deletions superset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def parse_manifest_json():
with open(MANIFEST_FILE, 'r') as f:
manifest = json.load(f)
except Exception:
print("no manifest file found at " + MANIFEST_FILE)
print('no manifest file found at ' + MANIFEST_FILE)


def get_manifest_file(filename):
Expand All @@ -66,7 +66,7 @@ def get_js_manifest():
print("Registering blueprint: '{}'".format(bp.name))
app.register_blueprint(bp)
except Exception as e:
print("blueprint registration failed")
print('blueprint registration failed')
logging.exception(e)

if conf.get('SILENCE_FAB'):
Expand All @@ -91,7 +91,7 @@ def get_js_manifest():
cache = utils.setup_cache(app, conf.get('CACHE_CONFIG'))
tables_cache = utils.setup_cache(app, conf.get('TABLE_NAMES_CACHE_CONFIG'))

migrate = Migrate(app, db, directory=APP_DIR + "/migrations")
migrate = Migrate(app, db, directory=APP_DIR + '/migrations')

# Logging configuration
logging.basicConfig(format=app.config.get('LOG_FORMAT'))
Expand Down Expand Up @@ -149,15 +149,15 @@ def index(self):
db.session,
base_template='superset/base.html',
indexview=MyIndexView,
security_manager_class=app.config.get("CUSTOM_SECURITY_MANAGER"))
security_manager_class=app.config.get('CUSTOM_SECURITY_MANAGER'))

sm = appbuilder.sm

results_backend = app.config.get("RESULTS_BACKEND")
results_backend = app.config.get('RESULTS_BACKEND')

# Registering sources
module_datasource_map = app.config.get("DEFAULT_MODULE_DS_MAP")
module_datasource_map.update(app.config.get("ADDITIONAL_MODULE_DS_MAP"))
module_datasource_map = app.config.get('DEFAULT_MODULE_DS_MAP')
module_datasource_map.update(app.config.get('ADDITIONAL_MODULE_DS_MAP'))
ConnectorRegistry.register_sources(module_datasource_map)

from superset import views # noqa
106 changes: 53 additions & 53 deletions superset/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,38 @@ def init():

@manager.option(
'-d', '--debug', action='store_true',
help="Start the web server in debug mode")
help='Start the web server in debug mode')
@manager.option(
'-n', '--no-reload', action='store_false', dest='no_reload',
default=config.get("FLASK_USE_RELOAD"),
default=config.get('FLASK_USE_RELOAD'),
help="Don't use the reloader in debug mode")
@manager.option(
'-a', '--address', default=config.get("SUPERSET_WEBSERVER_ADDRESS"),
help="Specify the address to which to bind the web server")
'-a', '--address', default=config.get('SUPERSET_WEBSERVER_ADDRESS'),
help='Specify the address to which to bind the web server')
@manager.option(
'-p', '--port', default=config.get("SUPERSET_WEBSERVER_PORT"),
help="Specify the port on which to run the web server")
'-p', '--port', default=config.get('SUPERSET_WEBSERVER_PORT'),
help='Specify the port on which to run the web server')
@manager.option(
'-w', '--workers',
default=config.get("SUPERSET_WORKERS", 2),
help="Number of gunicorn web server workers to fire up")
default=config.get('SUPERSET_WORKERS', 2),
help='Number of gunicorn web server workers to fire up')
@manager.option(
'-t', '--timeout', default=config.get("SUPERSET_WEBSERVER_TIMEOUT"),
help="Specify the timeout (seconds) for the gunicorn web server")
'-t', '--timeout', default=config.get('SUPERSET_WEBSERVER_TIMEOUT'),
help='Specify the timeout (seconds) for the gunicorn web server')
@manager.option(
'-s', '--socket', default=config.get("SUPERSET_WEBSERVER_SOCKET"),
help="Path to a UNIX socket as an alternative to address:port, e.g. "
"/var/run/superset.sock. "
"Will override the address and port values.")
'-s', '--socket', default=config.get('SUPERSET_WEBSERVER_SOCKET'),
help='Path to a UNIX socket as an alternative to address:port, e.g. '
'/var/run/superset.sock. '
'Will override the address and port values.')
def runserver(debug, no_reload, address, port, timeout, workers, socket):
"""Starts a Superset web server."""
debug = debug or config.get("DEBUG")
debug = debug or config.get('DEBUG')
if debug:
print(Fore.BLUE + '-=' * 20)
print(
Fore.YELLOW + "Starting Superset server in " +
Fore.RED + "DEBUG" +
Fore.YELLOW + " mode")
Fore.YELLOW + 'Starting Superset server in ' +
Fore.RED + 'DEBUG' +
Fore.YELLOW + ' mode')
print(Fore.BLUE + '-=' * 20)
print(Style.RESET_ALL)
app.run(
Expand All @@ -70,86 +70,86 @@ def runserver(debug, no_reload, address, port, timeout, workers, socket):
debug=True,
use_reloader=no_reload)
else:
addr_str = " unix:{socket} " if socket else" {address}:{port} "
addr_str = ' unix:{socket} ' if socket else' {address}:{port} '
cmd = (
"gunicorn "
"-w {workers} "
"--timeout {timeout} "
"-b " + addr_str +
"--limit-request-line 0 "
"--limit-request-field_size 0 "
"superset:app").format(**locals())
print(Fore.GREEN + "Starting server with command: ")
'gunicorn '
'-w {workers} '
'--timeout {timeout} '
'-b ' + addr_str +
'--limit-request-line 0 '
'--limit-request-field_size 0 '
'superset:app').format(**locals())
print(Fore.GREEN + 'Starting server with command: ')
print(Fore.YELLOW + cmd)
print(Style.RESET_ALL)
Popen(cmd, shell=True).wait()


@manager.option(
'-v', '--verbose', action='store_true',
help="Show extra information")
help='Show extra information')
def version(verbose):
"""Prints the current version number"""
print(Fore.BLUE + '-=' * 15)
print(Fore.YELLOW + "Superset " + Fore.CYAN + "{version}".format(
print(Fore.YELLOW + 'Superset ' + Fore.CYAN + '{version}'.format(
version=config.get('VERSION_STRING')))
print(Fore.BLUE + '-=' * 15)
if verbose:
print("[DB] : " + "{}".format(db.engine))
print('[DB] : ' + '{}'.format(db.engine))
print(Style.RESET_ALL)


@manager.option(
'-t', '--load-test-data', action='store_true',
help="Load additional test data")
help='Load additional test data')
def load_examples(load_test_data):
"""Loads a set of Slices and Dashboards and a supporting dataset """
from superset import data
print("Loading examples into {}".format(db))
print('Loading examples into {}'.format(db))

data.load_css_templates()

print("Loading energy related dataset")
print('Loading energy related dataset')
data.load_energy()

print("Loading [World Bank's Health Nutrition and Population Stats]")
data.load_world_bank_health_n_pop()

print("Loading [Birth names]")
print('Loading [Birth names]')
data.load_birth_names()

print("Loading [Random time series data]")
print('Loading [Random time series data]')
data.load_random_time_series_data()

print("Loading [Random long/lat data]")
print('Loading [Random long/lat data]')
data.load_long_lat_data()

print("Loading [Country Map data]")
print('Loading [Country Map data]')
data.load_country_map_data()

print("Loading [Multiformat time series]")
print('Loading [Multiformat time series]')
data.load_multiformat_time_series_data()

print("Loading [Misc Charts] dashboard")
print('Loading [Misc Charts] dashboard')
data.load_misc_dashboard()

if load_test_data:
print("Loading [Unicode test data]")
print('Loading [Unicode test data]')
data.load_unicode_test_data()


@manager.option(
'-d', '--datasource',
help=(
"Specify which datasource name to load, if omitted, all "
"datasources will be refreshed"
'Specify which datasource name to load, if omitted, all '
'datasources will be refreshed'
),
)
@manager.option(
'-m', '--merge',
help=(
"Specify using 'merge' property during operation. "
"Default value is False "
'Default value is False '
),
)
def refresh_druid(datasource, merge):
Expand All @@ -167,8 +167,8 @@ def refresh_druid(datasource, merge):
logging.exception(e)
cluster.metadata_last_refreshed = datetime.now()
print(
"Refreshed metadata from cluster "
"[" + cluster.cluster_name + "]")
'Refreshed metadata from cluster '
'[' + cluster.cluster_name + ']')
session.commit()


Expand All @@ -188,14 +188,14 @@ def update_datasources_cache():
@manager.option(
'-w', '--workers',
type=int,
help="Number of celery server workers to fire up")
help='Number of celery server workers to fire up')
def worker(workers):
"""Starts a Superset worker for async SQL query execution."""
if workers:
celery_app.conf.update(CELERYD_CONCURRENCY=workers)
elif config.get("SUPERSET_CELERY_WORKERS"):
elif config.get('SUPERSET_CELERY_WORKERS'):
celery_app.conf.update(
CELERYD_CONCURRENCY=config.get("SUPERSET_CELERY_WORKERS"))
CELERYD_CONCURRENCY=config.get('SUPERSET_CELERY_WORKERS'))

worker = celery_app.Worker(optimization='fair')
worker.start()
Expand All @@ -216,12 +216,12 @@ def flower(port, address):
broker"""
BROKER_URL = celery_app.conf.BROKER_URL
cmd = (
"celery flower "
"--broker={BROKER_URL} "
"--port={port} "
"--address={address} "
'celery flower '
'--broker={BROKER_URL} '
'--port={port} '
'--address={address} '
).format(**locals())
print(Fore.GREEN + "Starting a Celery Flower instance")
print(Fore.GREEN + 'Starting a Celery Flower instance')
print(Fore.BLUE + '-=' * 40)
print(Fore.YELLOW + cmd)
print(Fore.BLUE + '-=' * 40)
Expand Down
8 changes: 4 additions & 4 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@
# GLOBALS FOR APP Builder
# ------------------------------
# Uncomment to setup Your App name
APP_NAME = "Superset"
APP_NAME = 'Superset'

# Uncomment to setup an App icon
APP_ICON = "/static/assets/images/superset-logo@2x.png"
APP_ICON = '/static/assets/images/superset-logo@2x.png'

# Druid query timezone
# tz.tzutc() : Using utc timezone
Expand Down Expand Up @@ -239,7 +239,7 @@
BACKUP_COUNT = 30

# Set this API key to enable Mapbox visualizations
MAPBOX_API_KEY = ""
MAPBOX_API_KEY = ''

# Maximum number of rows returned in the SQL editor
SQL_MAX_ROW = 1000000
Expand Down Expand Up @@ -329,7 +329,7 @@ class CeleryConfig(object):

# The link to a page containing common errors and their resolutions
# It will be appended at the bottom of sql_lab errors.
TROUBLESHOOTING_LINK = ""
TROUBLESHOOTING_LINK = ''


# Integrate external Blueprints to the app by passing them to your
Expand Down
6 changes: 3 additions & 3 deletions superset/connectors/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def slices(self):
@property
def uid(self):
"""Unique id across datasource types"""
return "{self.id}__{self.type}".format(**locals())
return '{self.id}__{self.type}'.format(**locals())

@property
def column_names(self):
Expand All @@ -72,7 +72,7 @@ def columns_types(self):

@property
def main_dttm_col(self):
return "timestamp"
return 'timestamp'

@property
def connection(self):
Expand Down Expand Up @@ -105,7 +105,7 @@ def explore_url(self):
if self.default_endpoint:
return self.default_endpoint
else:
return "/superset/explore/{obj.type}/{obj.id}/".format(obj=self)
return '/superset/explore/{obj.type}/{obj.id}/'.format(obj=self)

@property
def column_formats(self):
Expand Down
4 changes: 2 additions & 2 deletions superset/connectors/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class DatasourceModelView(SupersetModelView):
def pre_delete(self, obj):
if obj.slices:
raise SupersetException(Markup(
"Cannot delete a datasource that has slices attached to it."
'Cannot delete a datasource that has slices attached to it.'
"Here's the list of associated slices: " +
"".join([o.slice_link for o in obj.slices])))
''.join([o.slice_link for o in obj.slices])))
Loading