mirror of
https://github.com/apache/superset.git
synced 2026-04-21 00:54:44 +00:00
pylint: accept specific 2 character names by default (#9460)
* lint: accept 2 letter names by default * Address review comments * Remove e and d from good-names
This commit is contained in:
@@ -185,8 +185,8 @@ def check_datasource_perms(
|
||||
datasource_id, datasource_type = get_datasource_info(
|
||||
datasource_id, datasource_type, form_data
|
||||
)
|
||||
except SupersetException as e:
|
||||
raise SupersetSecurityException(str(e))
|
||||
except SupersetException as ex:
|
||||
raise SupersetSecurityException(str(ex))
|
||||
|
||||
if datasource_type is None:
|
||||
raise SupersetSecurityException("Could not determine datasource type")
|
||||
@@ -317,8 +317,8 @@ class KV(BaseSupersetView):
|
||||
obj = models.KeyValue(value=value)
|
||||
db.session.add(obj)
|
||||
db.session.commit()
|
||||
except Exception as e:
|
||||
return json_error_response(e)
|
||||
except Exception as ex:
|
||||
return json_error_response(ex)
|
||||
return Response(json.dumps({"id": obj.id}), status=200)
|
||||
|
||||
@event_logger.log_this
|
||||
@@ -329,8 +329,8 @@ class KV(BaseSupersetView):
|
||||
kv = db.session.query(models.KeyValue).filter_by(id=key_id).scalar()
|
||||
if not kv:
|
||||
return Response(status=404, content_type="text/plain")
|
||||
except Exception as e:
|
||||
return json_error_response(e)
|
||||
except Exception as ex:
|
||||
return json_error_response(ex)
|
||||
return Response(kv.value, status=200, content_type="text/plain")
|
||||
|
||||
|
||||
@@ -600,9 +600,9 @@ class Superset(BaseSupersetView):
|
||||
query_obj = viz_obj.query_obj()
|
||||
if query_obj:
|
||||
query = viz_obj.datasource.get_query_str(query_obj)
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
return json_error_response(e)
|
||||
except Exception as ex:
|
||||
logger.exception(ex)
|
||||
return json_error_response(ex)
|
||||
|
||||
if not query:
|
||||
query = "No query."
|
||||
@@ -706,8 +706,8 @@ class Superset(BaseSupersetView):
|
||||
datasource_id, datasource_type = get_datasource_info(
|
||||
datasource_id, datasource_type, form_data
|
||||
)
|
||||
except SupersetException as e:
|
||||
return json_error_response(utils.error_msg_from_exception(e))
|
||||
except SupersetException as ex:
|
||||
return json_error_response(utils.error_msg_from_exception(ex))
|
||||
|
||||
viz_obj = get_viz(
|
||||
datasource_type=datasource_type,
|
||||
@@ -729,19 +729,19 @@ class Superset(BaseSupersetView):
|
||||
if request.method == "POST" and f:
|
||||
try:
|
||||
dashboard_import_export.import_dashboards(db.session, f.stream)
|
||||
except DatabaseNotFound as e:
|
||||
logger.exception(e)
|
||||
except DatabaseNotFound as ex:
|
||||
logger.exception(ex)
|
||||
flash(
|
||||
_(
|
||||
"Cannot import dashboard: %(db_error)s.\n"
|
||||
"Make sure to create the database before "
|
||||
"importing the dashboard.",
|
||||
db_error=e,
|
||||
db_error=ex,
|
||||
),
|
||||
"danger",
|
||||
)
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
except Exception as ex:
|
||||
logger.exception(ex)
|
||||
flash(
|
||||
_(
|
||||
"An unknown error occurred. "
|
||||
@@ -1371,11 +1371,11 @@ class Superset(BaseSupersetView):
|
||||
with closing(engine.connect()) as conn:
|
||||
conn.scalar(select([1]))
|
||||
return json_success('"OK"')
|
||||
except CertificateException as e:
|
||||
logger.info(e.message)
|
||||
return json_error_response(e.message)
|
||||
except NoSuchModuleError as e:
|
||||
logger.info("Invalid driver %s", e)
|
||||
except CertificateException as ex:
|
||||
logger.info(ex.message)
|
||||
return json_error_response(ex.message)
|
||||
except NoSuchModuleError as ex:
|
||||
logger.info("Invalid driver %s", ex)
|
||||
driver_name = make_url(uri).drivername
|
||||
return json_error_response(
|
||||
_(
|
||||
@@ -1384,24 +1384,24 @@ class Superset(BaseSupersetView):
|
||||
),
|
||||
400,
|
||||
)
|
||||
except ArgumentError as e:
|
||||
logger.info("Invalid URI %s", e)
|
||||
except ArgumentError as ex:
|
||||
logger.info("Invalid URI %s", ex)
|
||||
return json_error_response(
|
||||
_(
|
||||
"Invalid connection string, a valid string usually follows:\n"
|
||||
"'DRIVER://USER:PASSWORD@DB-HOST/DATABASE-NAME'"
|
||||
)
|
||||
)
|
||||
except OperationalError as e:
|
||||
logger.warning("Connection failed %s", e)
|
||||
except OperationalError as ex:
|
||||
logger.warning("Connection failed %s", ex)
|
||||
return json_error_response(
|
||||
_("Connection failed, please check your connection settings."), 400
|
||||
)
|
||||
except DBSecurityException as e:
|
||||
logger.warning("Stopped an unsafe database connection. %s", e)
|
||||
return json_error_response(_(str(e)), 400)
|
||||
except Exception as e:
|
||||
logger.error("Unexpected error %s", e)
|
||||
except DBSecurityException as ex:
|
||||
logger.warning("Stopped an unsafe database connection. %s", ex)
|
||||
return json_error_response(_(str(ex)), 400)
|
||||
except Exception as ex:
|
||||
logger.error("Unexpected error %s", ex)
|
||||
return json_error_response(
|
||||
_("Unexpected error occurred, please check your logs for details"), 400
|
||||
)
|
||||
@@ -1706,9 +1706,9 @@ class Superset(BaseSupersetView):
|
||||
force=True,
|
||||
)
|
||||
obj.get_json()
|
||||
except Exception as e:
|
||||
except Exception as ex:
|
||||
logger.exception("Failed to warm up cache")
|
||||
return json_error_response(utils.error_msg_from_exception(e))
|
||||
return json_error_response(utils.error_msg_from_exception(ex))
|
||||
return json_success(
|
||||
json.dumps(
|
||||
[{"slice_id": slc.id, "slice_name": slc.slice_name} for slc in slices]
|
||||
@@ -1950,9 +1950,9 @@ class Superset(BaseSupersetView):
|
||||
return json_error_response(err_msg)
|
||||
try:
|
||||
DruidDatasource.sync_to_db_from_config(druid_config, user, cluster)
|
||||
except Exception as e:
|
||||
logger.exception(utils.error_msg_from_exception(e))
|
||||
return json_error_response(utils.error_msg_from_exception(e))
|
||||
except Exception as ex:
|
||||
logger.exception(utils.error_msg_from_exception(ex))
|
||||
return json_error_response(utils.error_msg_from_exception(ex))
|
||||
return Response(status=201)
|
||||
|
||||
@has_access
|
||||
@@ -2064,11 +2064,11 @@ class Superset(BaseSupersetView):
|
||||
cost = mydb.db_engine_spec.estimate_query_cost(
|
||||
mydb, schema, sql, utils.QuerySource.SQL_LAB
|
||||
)
|
||||
except SupersetTimeoutException as e:
|
||||
logger.exception(e)
|
||||
except SupersetTimeoutException as ex:
|
||||
logger.exception(ex)
|
||||
return json_error_response(timeout_msg)
|
||||
except Exception as e:
|
||||
return json_error_response(str(e))
|
||||
except Exception as ex:
|
||||
return json_error_response(str(ex))
|
||||
|
||||
spec = mydb.db_engine_spec
|
||||
query_cost_formatters = get_feature_flags().get(
|
||||
@@ -2226,15 +2226,15 @@ class Superset(BaseSupersetView):
|
||||
encoding=None,
|
||||
)
|
||||
return json_success(payload)
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
except Exception as ex:
|
||||
logger.exception(ex)
|
||||
msg = _(
|
||||
f"{validator.name} was unable to check your query.\n"
|
||||
"Please recheck your query.\n"
|
||||
f"Exception: {e}"
|
||||
f"Exception: {ex}"
|
||||
)
|
||||
# Return as a 400 if the database error message says we got a 4xx error
|
||||
if re.search(r"([\W]|^)4\d{2}([\W]|$)", str(e)):
|
||||
if re.search(r"([\W]|^)4\d{2}([\W]|$)", str(ex)):
|
||||
return json_error_response(f"{msg}", status=400)
|
||||
else:
|
||||
return json_error_response(f"{msg}")
|
||||
@@ -2268,8 +2268,8 @@ class Superset(BaseSupersetView):
|
||||
expand_data=expand_data,
|
||||
log_params=log_params,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.exception(f"Query {query.id}: {e}")
|
||||
except Exception as ex:
|
||||
logger.exception(f"Query {query.id}: {ex}")
|
||||
msg = _(
|
||||
"Failed to start remote query on a worker. "
|
||||
"Tell your administrator to verify the availability of "
|
||||
@@ -2330,8 +2330,8 @@ class Superset(BaseSupersetView):
|
||||
ignore_nan=True,
|
||||
encoding=None,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.exception(f"Query {query.id}: {e}")
|
||||
except Exception as ex:
|
||||
logger.exception(f"Query {query.id}: {ex}")
|
||||
return json_error_response(f"{{e}}")
|
||||
if data.get("status") == QueryStatus.FAILED:
|
||||
return json_error_response(payload=data)
|
||||
@@ -2414,8 +2414,8 @@ class Superset(BaseSupersetView):
|
||||
session.flush()
|
||||
query_id = query.id
|
||||
session.commit() # shouldn't be necessary
|
||||
except SQLAlchemyError as e:
|
||||
logger.error(f"Errors saving query details {e}")
|
||||
except SQLAlchemyError as ex:
|
||||
logger.error(f"Errors saving query details {ex}")
|
||||
session.rollback()
|
||||
raise Exception(_("Query record was not created as expected."))
|
||||
if not query_id:
|
||||
@@ -2440,8 +2440,8 @@ class Superset(BaseSupersetView):
|
||||
rendered_query = template_processor.process_template(
|
||||
query.sql, **template_params
|
||||
)
|
||||
except Exception as e:
|
||||
error_msg = utils.error_msg_from_exception(e)
|
||||
except Exception as ex:
|
||||
error_msg = utils.error_msg_from_exception(ex)
|
||||
return json_error_response(
|
||||
f"Query {query_id}: Template rendering failed: {error_msg}"
|
||||
)
|
||||
@@ -2799,8 +2799,8 @@ class Superset(BaseSupersetView):
|
||||
database, schemas_allowed, False
|
||||
)
|
||||
return self.json_response(schemas_allowed_processed)
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
except Exception as ex:
|
||||
logger.exception(ex)
|
||||
return json_error_response(
|
||||
"Failed to fetch schemas allowed for csv upload in this database! "
|
||||
"Please contact your Superset Admin!"
|
||||
|
||||
Reference in New Issue
Block a user