)[tone]
+ : undefined;
return (
| ,
+ TimeFormatValidatorState
+> {
+ state: TimeFormatValidatorState = {
formatString: '%Y-%m-%d %H:%M:%S',
testValues: [
new Date(Date.UTC(1986, 5, 14, 8, 30, 53)),
@@ -37,12 +42,12 @@ class TimeFormatValidator extends PureComponent {
],
};
- constructor(props) {
+ constructor(props: Record) {
super(props);
this.handleFormatChange = this.handleFormatChange.bind(this);
}
- handleFormatChange(event) {
+ handleFormatChange(event: React.ChangeEvent) {
this.setState({
formatString: event.target.value,
});
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/ActionButtons/ActionButtons.test.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/ActionButtons/ActionButtons.test.tsx
index 93031da42be..1ac583ef99d 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/ActionButtons/ActionButtons.test.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/ActionButtons/ActionButtons.test.tsx
@@ -82,10 +82,9 @@ describe('custom width', () => {
const mockedProps = createProps();
render(, { useRedux: true });
const container = screen.getByTestId('filterbar-action-buttons');
- expect(container).toHaveStyleRule(
- 'width',
- `${OPEN_FILTER_BAR_WIDTH - 1}px`,
- );
+ expect(container).toHaveStyle({
+ width: `${OPEN_FILTER_BAR_WIDTH - 1}px`,
+ });
});
it('sets custom width', () => {
@@ -98,6 +97,8 @@ describe('custom width', () => {
},
);
const container = getByTestId('filterbar-action-buttons');
- expect(container).toHaveStyleRule('width', `${expectedWidth - 1}px`);
+ expect(container).toHaveStyle({
+ width: `${expectedWidth - 1}px`,
+ });
});
});
diff --git a/superset-frontend/src/explore/actions/datasourcesActions.ts b/superset-frontend/src/explore/actions/datasourcesActions.ts
index 54990c6f38e..36d7767df9c 100644
--- a/superset-frontend/src/explore/actions/datasourcesActions.ts
+++ b/superset-frontend/src/explore/actions/datasourcesActions.ts
@@ -25,6 +25,17 @@ import { addDangerToast } from 'src/components/MessageToasts/actions';
import { updateFormDataByDatasource } from './exploreActions';
import { ExplorePageState } from '../types';
+interface SaveDatasetRequest {
+ data: {
+ schema?: string;
+ sql?: string;
+ dbId?: number;
+ templateParams?: string;
+ datasourceName: string;
+ columns: unknown[];
+ };
+}
+
export const SET_DATASOURCE = 'SET_DATASOURCE';
export interface SetDatasource {
type: string;
@@ -51,7 +62,7 @@ export function saveDataset({
templateParams,
datasourceName,
columns,
-}: Omit & { database: { id: number } }) {
+}: Omit & { database: { id: number } }) {
return async function (dispatch: ThunkDispatch) {
// Create a dataset object
try {
diff --git a/superset-frontend/src/types/react-syntax-highlighter.d.ts b/superset-frontend/src/types/react-syntax-highlighter.d.ts
new file mode 100644
index 00000000000..f0860387ddf
--- /dev/null
+++ b/superset-frontend/src/types/react-syntax-highlighter.d.ts
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+declare module 'react-syntax-highlighter/dist/cjs/light' {
+ import SyntaxHighlighter from 'react-syntax-highlighter';
+ export default SyntaxHighlighter;
+}
+
+declare module 'react-syntax-highlighter/dist/cjs/styles/hljs/github' {
+ const style: any;
+ export default style;
+}
+
+type SupportedLanguages = 'markdown' | 'htmlbars' | 'sql' | 'json';
+
+// For type checking when importing languages
+function importLanguage(language: T) {
+ return import(`react-syntax-highlighter/dist/cjs/languages/hljs/${language}`);
+}
diff --git a/superset/charts/api.py b/superset/charts/api.py
index 292575feac4..f8f59c875b5 100644
--- a/superset/charts/api.py
+++ b/superset/charts/api.py
@@ -890,8 +890,7 @@ class ChartRestApi(BaseSupersetModelRestApi):
@safe
@statsd_metrics
@event_logger.log_this_with_context(
- action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
- f".add_favorite",
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.add_favorite",
log_to_statsd=False,
)
def add_favorite(self, pk: int) -> Response:
@@ -980,8 +979,7 @@ class ChartRestApi(BaseSupersetModelRestApi):
@safe
@statsd_metrics
@event_logger.log_this_with_context(
- action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
- f".warm_up_cache",
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.warm_up_cache",
log_to_statsd=False,
)
def warm_up_cache(self) -> Response:
diff --git a/superset/charts/schemas.py b/superset/charts/schemas.py
index 7faa42aebc5..75989597a37 100644
--- a/superset/charts/schemas.py
+++ b/superset/charts/schemas.py
@@ -801,8 +801,7 @@ class ChartDataPivotOptionsSchema(ChartDataPostProcessingOperationOptionsSchema)
)
marginal_distribution_name = fields.String(
metadata={
- "description": "Name of marginal distribution row/column. "
- "(default: `All`)"
+ "description": "Name of marginal distribution row/column. (default: `All`)"
},
)
aggregates = ChartDataAggregateConfigField()
diff --git a/superset/cli/thumbnails.py b/superset/cli/thumbnails.py
index 0dd8edfb130..2a0afb1a6b1 100755
--- a/superset/cli/thumbnails.py
+++ b/superset/cli/thumbnails.py
@@ -91,7 +91,7 @@ def compute_thumbnails(
else:
func = compute_func
action = "Processing"
- msg = f'{action} {friendly_type} "{model}" ({i+1}/{count})'
+ msg = f'{action} {friendly_type} "{model}" ({i + 1}/{count})'
click.secho(msg, fg="green")
func(None, model.id, force=force)
diff --git a/superset/common/db_query_status.py b/superset/common/db_query_status.py
index fa893a17171..52778729ad1 100644
--- a/superset/common/db_query_status.py
+++ b/superset/common/db_query_status.py
@@ -20,11 +20,11 @@ from superset.utils.backports import StrEnum
class QueryStatus(StrEnum):
"""Enum-type class for query statuses"""
- STOPPED: str = "stopped"
- FAILED: str = "failed"
- PENDING: str = "pending"
- RUNNING: str = "running"
- SCHEDULED: str = "scheduled"
- SUCCESS: str = "success"
- FETCHING: str = "fetching"
- TIMED_OUT: str = "timed_out"
+ STOPPED = "stopped"
+ FAILED = "failed"
+ PENDING = "pending"
+ RUNNING = "running"
+ SCHEDULED = "scheduled"
+ SUCCESS = "success"
+ FETCHING = "fetching"
+ TIMED_OUT = "timed_out"
diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py
index 7d0570b92b8..6478fdf075d 100644
--- a/superset/connectors/sqla/models.py
+++ b/superset/connectors/sqla/models.py
@@ -1367,7 +1367,7 @@ class SqlaTable(
df.columns = ["field", "type"]
return df.to_html(
index=False,
- classes=("dataframe table table-striped table-bordered " "table-condensed"),
+ classes=("dataframe table table-striped table-bordered table-condensed"),
)
@property
diff --git a/superset/dashboards/api.py b/superset/dashboards/api.py
index 2eca96dfeba..f5979095e25 100644
--- a/superset/dashboards/api.py
+++ b/superset/dashboards/api.py
@@ -1374,8 +1374,7 @@ class DashboardRestApi(BaseSupersetModelRestApi):
@safe
@statsd_metrics
@event_logger.log_this_with_context(
- action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
- f".add_favorite",
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.add_favorite",
log_to_statsd=False,
)
def add_favorite(self, pk: int) -> Response:
diff --git a/superset/dashboards/schemas.py b/superset/dashboards/schemas.py
index d0b6230dcea..ded83246691 100644
--- a/superset/dashboards/schemas.py
+++ b/superset/dashboards/schemas.py
@@ -70,8 +70,7 @@ json_metadata_description = (
" specific parameters."
)
published_description = (
- "Determines whether or not this dashboard is visible in "
- "the list of all dashboards."
+ "Determines whether or not this dashboard is visible in the list of all dashboards."
)
charts_description = (
"The names of the dashboard's charts. Names are used for legacy reasons."
diff --git a/superset/databases/api.py b/superset/databases/api.py
index f9c1dfd122e..22433612a8d 100644
--- a/superset/databases/api.py
+++ b/superset/databases/api.py
@@ -563,7 +563,7 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
@safe
@statsd_metrics
@event_logger.log_this_with_context(
- action=lambda self, *args, **kwargs: f"{self.__class__.__name__}" f".delete",
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.delete",
log_to_statsd=False,
)
def delete(self, pk: int) -> Response:
@@ -618,7 +618,7 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
@rison(database_catalogs_query_schema)
@statsd_metrics
@event_logger.log_this_with_context(
- action=lambda self, *args, **kwargs: f"{self.__class__.__name__}" f".catalogs",
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.catalogs",
log_to_statsd=False,
)
def catalogs(self, pk: int, **kwargs: Any) -> FlaskResponse:
@@ -683,7 +683,7 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
@rison(database_schemas_query_schema)
@statsd_metrics
@event_logger.log_this_with_context(
- action=lambda self, *args, **kwargs: f"{self.__class__.__name__}" f".schemas",
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.schemas",
log_to_statsd=False,
)
def schemas(self, pk: int, **kwargs: Any) -> FlaskResponse:
@@ -751,7 +751,7 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
@statsd_metrics
@handle_api_exception
@event_logger.log_this_with_context(
- action=lambda self, *args, **kwargs: f"{self.__class__.__name__}" f".tables",
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.tables",
log_to_statsd=False,
)
def tables(self, pk: int, **kwargs: Any) -> FlaskResponse:
@@ -1618,8 +1618,7 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
@statsd_metrics
@event_logger.log_this_with_context(
action=(
- lambda self, *args, **kwargs: f"{self.__class__.__name__}"
- ".upload_metadata"
+ lambda self, *args, **kwargs: f"{self.__class__.__name__}.upload_metadata"
),
log_to_statsd=False,
)
@@ -1784,7 +1783,7 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
@protect()
@statsd_metrics
@event_logger.log_this_with_context(
- action=lambda self, *args, **kwargs: f"{self.__class__.__name__}" f".available",
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.available",
log_to_statsd=False,
)
def available(self) -> Response:
diff --git a/superset/databases/schemas.py b/superset/databases/schemas.py
index 8312a7a1b28..e455ff7445f 100644
--- a/superset/databases/schemas.py
+++ b/superset/databases/schemas.py
@@ -106,9 +106,7 @@ allow_file_upload_description = (
allow_ctas_description = "Allow CREATE TABLE AS option in SQL Lab"
allow_cvas_description = "Allow CREATE VIEW AS option in SQL Lab"
allow_dml_description = (
- "Allow users to run non-SELECT statements "
- "(UPDATE, DELETE, CREATE, ...) "
- "in SQL Lab"
+ "Allow users to run non-SELECT statements (UPDATE, DELETE, CREATE, ...) in SQL Lab"
)
configuration_method_description = (
"Configuration_method is used on the frontend to "
diff --git a/superset/datasets/api.py b/superset/datasets/api.py
index b9094f30639..b41f6395bd7 100644
--- a/superset/datasets/api.py
+++ b/superset/datasets/api.py
@@ -568,7 +568,7 @@ class DatasetRestApi(BaseSupersetModelRestApi):
@safe
@statsd_metrics
@event_logger.log_this_with_context(
- action=lambda self, *args, **kwargs: f"{self.__class__.__name__}" f".duplicate",
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.duplicate",
log_to_statsd=False,
)
@requires_json
@@ -638,7 +638,7 @@ class DatasetRestApi(BaseSupersetModelRestApi):
@safe
@statsd_metrics
@event_logger.log_this_with_context(
- action=lambda self, *args, **kwargs: f"{self.__class__.__name__}" f".refresh",
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.refresh",
log_to_statsd=False,
)
def refresh(self, pk: int) -> Response:
@@ -1016,8 +1016,7 @@ class DatasetRestApi(BaseSupersetModelRestApi):
@safe
@statsd_metrics
@event_logger.log_this_with_context(
- action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
- f".warm_up_cache",
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.warm_up_cache",
log_to_statsd=False,
)
def warm_up_cache(self) -> Response:
@@ -1075,7 +1074,7 @@ class DatasetRestApi(BaseSupersetModelRestApi):
@statsd_metrics
@handle_api_exception
@event_logger.log_this_with_context(
- action=lambda self, *args, **kwargs: f"{self.__class__.__name__}" f".get",
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.get",
log_to_statsd=False,
)
def get(self, pk: int, **kwargs: Any) -> Response:
diff --git a/superset/db_engine_specs/base.py b/superset/db_engine_specs/base.py
index f239ef20192..248f8bd0a78 100644
--- a/superset/db_engine_specs/base.py
+++ b/superset/db_engine_specs/base.py
@@ -2434,7 +2434,7 @@ class BasicParametersMixin:
if missing := sorted(required - present):
errors.append(
SupersetError(
- message=f'One or more parameters are missing: {", ".join(missing)}',
+ message=f"One or more parameters are missing: {', '.join(missing)}",
error_type=SupersetErrorType.CONNECTION_MISSING_PARAMETERS_ERROR,
level=ErrorLevel.WARNING,
extra={"missing": missing},
@@ -2473,8 +2473,7 @@ class BasicParametersMixin:
errors.append(
SupersetError(
message=(
- "The port must be an integer between 0 and 65535 "
- "(inclusive)."
+ "The port must be an integer between 0 and 65535 (inclusive)."
),
error_type=SupersetErrorType.CONNECTION_INVALID_PORT_ERROR,
level=ErrorLevel.ERROR,
diff --git a/superset/db_engine_specs/couchbase.py b/superset/db_engine_specs/couchbase.py
index ac48ef11fb0..6cb8378c9ef 100644
--- a/superset/db_engine_specs/couchbase.py
+++ b/superset/db_engine_specs/couchbase.py
@@ -187,7 +187,7 @@ class CouchbaseEngineSpec(BasicParametersMixin, BaseEngineSpec):
if missing := sorted(required - present):
errors.append(
SupersetError(
- message=f'One or more parameters are missing: {", ".join(missing)}',
+ message=f"One or more parameters are missing: {', '.join(missing)}",
error_type=SupersetErrorType.CONNECTION_MISSING_PARAMETERS_ERROR,
level=ErrorLevel.WARNING,
extra={"missing": missing},
diff --git a/superset/db_engine_specs/databricks.py b/superset/db_engine_specs/databricks.py
index 1395ca3aa28..18056826077 100644
--- a/superset/db_engine_specs/databricks.py
+++ b/superset/db_engine_specs/databricks.py
@@ -288,7 +288,7 @@ class DatabricksDynamicBaseEngineSpec(BasicParametersMixin, DatabricksBaseEngine
if missing := sorted(cls.required_parameters - present):
errors.append(
SupersetError(
- message=f'One or more parameters are missing: {", ".join(missing)}',
+ message=f"One or more parameters are missing: {', '.join(missing)}",
error_type=SupersetErrorType.CONNECTION_MISSING_PARAMETERS_ERROR,
level=ErrorLevel.WARNING,
extra={"missing": missing},
@@ -328,8 +328,7 @@ class DatabricksDynamicBaseEngineSpec(BasicParametersMixin, DatabricksBaseEngine
errors.append(
SupersetError(
message=(
- "The port must be an integer between 0 and 65535 "
- "(inclusive)."
+ "The port must be an integer between 0 and 65535 (inclusive)."
),
error_type=SupersetErrorType.CONNECTION_INVALID_PORT_ERROR,
level=ErrorLevel.ERROR,
diff --git a/superset/db_engine_specs/duckdb.py b/superset/db_engine_specs/duckdb.py
index 9a3ce725801..8fd5ab62b82 100644
--- a/superset/db_engine_specs/duckdb.py
+++ b/superset/db_engine_specs/duckdb.py
@@ -162,7 +162,7 @@ class DuckDBParametersMixin:
if missing := sorted(required - present):
errors.append(
SupersetError(
- message=f'One or more parameters are missing: {", ".join(missing)}',
+ message=f"One or more parameters are missing: {', '.join(missing)}",
error_type=SupersetErrorType.CONNECTION_MISSING_PARAMETERS_ERROR,
level=ErrorLevel.WARNING,
extra={"missing": missing},
diff --git a/superset/db_engine_specs/hana.py b/superset/db_engine_specs/hana.py
index da05fba847d..13b5674c87a 100644
--- a/superset/db_engine_specs/hana.py
+++ b/superset/db_engine_specs/hana.py
@@ -53,6 +53,7 @@ class HanaEngineSpec(PostgresBaseEngineSpec):
if isinstance(sqla_type, types.Date):
return f"TO_DATE('{dttm.date().isoformat()}', 'YYYY-MM-DD')"
if isinstance(sqla_type, types.TIMESTAMP):
- return f"""TO_TIMESTAMP('{dttm
- .isoformat(timespec="microseconds")}', 'YYYY-MM-DD"T"HH24:MI:SS.ff6')"""
+ return f"""TO_TIMESTAMP('{
+ dttm.isoformat(timespec="microseconds")
+ }', 'YYYY-MM-DD"T"HH24:MI:SS.ff6')"""
return None
diff --git a/superset/db_engine_specs/hive.py b/superset/db_engine_specs/hive.py
index 55e1187402a..9b7afab1cc5 100644
--- a/superset/db_engine_specs/hive.py
+++ b/superset/db_engine_specs/hive.py
@@ -261,8 +261,9 @@ class HiveEngineSpec(PrestoEngineSpec):
if isinstance(sqla_type, types.Date):
return f"CAST('{dttm.date().isoformat()}' AS DATE)"
if isinstance(sqla_type, types.TIMESTAMP):
- return f"""CAST('{dttm
- .isoformat(sep=" ", timespec="microseconds")}' AS TIMESTAMP)"""
+ return f"""CAST('{
+ dttm.isoformat(sep=" ", timespec="microseconds")
+ }' AS TIMESTAMP)"""
return None
@classmethod
diff --git a/superset/db_engine_specs/oracle.py b/superset/db_engine_specs/oracle.py
index b98ab8ed59e..f03cea49120 100644
--- a/superset/db_engine_specs/oracle.py
+++ b/superset/db_engine_specs/oracle.py
@@ -51,8 +51,9 @@ class OracleEngineSpec(BaseEngineSpec):
if isinstance(sqla_type, types.Date):
return f"TO_DATE('{dttm.date().isoformat()}', 'YYYY-MM-DD')"
if isinstance(sqla_type, types.TIMESTAMP):
- return f"""TO_TIMESTAMP('{dttm
- .isoformat(timespec="microseconds")}', 'YYYY-MM-DD"T"HH24:MI:SS.ff6')"""
+ return f"""TO_TIMESTAMP('{
+ dttm.isoformat(timespec="microseconds")
+ }', 'YYYY-MM-DD"T"HH24:MI:SS.ff6')"""
if isinstance(sqla_type, types.DateTime):
datetime_formatted = dttm.isoformat(timespec="seconds")
return f"""TO_DATE('{datetime_formatted}', 'YYYY-MM-DD"T"HH24:MI:SS')"""
diff --git a/superset/db_engine_specs/presto.py b/superset/db_engine_specs/presto.py
index 6f27503a2f2..e351c5b3070 100644
--- a/superset/db_engine_specs/presto.py
+++ b/superset/db_engine_specs/presto.py
@@ -664,7 +664,7 @@ class PrestoBaseEngineSpec(BaseEngineSpec, metaclass=ABCMeta):
if len(kwargs.keys()) != len(part_fields) - 1:
# pylint: disable=consider-using-f-string
msg = (
- "A filter needs to be specified for {} out of the " "{} fields."
+ "A filter needs to be specified for {} out of the {} fields."
).format(len(part_fields) - 1, len(part_fields))
raise SupersetTemplateException(msg)
diff --git a/superset/db_engine_specs/snowflake.py b/superset/db_engine_specs/snowflake.py
index 9680628d06b..a99f1e641d6 100644
--- a/superset/db_engine_specs/snowflake.py
+++ b/superset/db_engine_specs/snowflake.py
@@ -336,7 +336,7 @@ class SnowflakeEngineSpec(PostgresBaseEngineSpec):
if missing := sorted(required - present):
errors.append(
SupersetError(
- message=f'One or more parameters are missing: {", ".join(missing)}',
+ message=f"One or more parameters are missing: {', '.join(missing)}",
error_type=SupersetErrorType.CONNECTION_MISSING_PARAMETERS_ERROR,
level=ErrorLevel.WARNING,
extra={"missing": missing},
diff --git a/superset/migrations/versions/2020-09-28_17-57_b56500de1855_add_uuid_column_to_import_mixin.py b/superset/migrations/versions/2020-09-28_17-57_b56500de1855_add_uuid_column_to_import_mixin.py
index 57c9917ce46..28f56ed4177 100644
--- a/superset/migrations/versions/2020-09-28_17-57_b56500de1855_add_uuid_column_to_import_mixin.py
+++ b/superset/migrations/versions/2020-09-28_17-57_b56500de1855_add_uuid_column_to_import_mixin.py
@@ -111,7 +111,7 @@ def update_dashboards(session, uuid_map):
update_position_json(dashboard, session, uuid_map)
if i and i % default_batch_size == 0:
session.commit()
- print(f"{message} {i+1}/{dashboard_count}\r", end="")
+ print(f"{message} {i + 1}/{dashboard_count}\r", end="")
session.commit()
# Extra whitespace to override very long numbers, e.g. 99999/99999.
diff --git a/superset/migrations/versions/2022-04-01_14-38_a9422eeaae74_new_dataset_models_take_2.py b/superset/migrations/versions/2022-04-01_14-38_a9422eeaae74_new_dataset_models_take_2.py
index 2a76a955403..bc666b559de 100644
--- a/superset/migrations/versions/2022-04-01_14-38_a9422eeaae74_new_dataset_models_take_2.py
+++ b/superset/migrations/versions/2022-04-01_14-38_a9422eeaae74_new_dataset_models_take_2.py
@@ -867,15 +867,17 @@ new_tables: sa.Table = [
def reset_postgres_id_sequence(table: str) -> None:
+ """Reset PostgreSQL sequence ID for a table's id column."""
op.execute(
- f"""
+ """
SELECT setval(
- pg_get_serial_sequence('{table}', 'id'),
+ pg_get_serial_sequence(:table, 'id'),
COALESCE(max(id) + 1, 1),
false
)
- FROM {table};
- """
+ FROM :table;
+ """,
+ {"table": table},
)
diff --git a/superset/queries/api.py b/superset/queries/api.py
index 5d1ed10d065..7e383e95bc1 100644
--- a/superset/queries/api.py
+++ b/superset/queries/api.py
@@ -225,8 +225,7 @@ class QueryRestApi(BaseSupersetModelRestApi):
@safe
@statsd_metrics
@event_logger.log_this_with_context(
- action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
- f".stop_query",
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.stop_query",
log_to_statsd=False,
)
@backoff.on_exception(
diff --git a/superset/sql_lab.py b/superset/sql_lab.py
index 25ac9a5c5c8..7f4a0f1c991 100644
--- a/superset/sql_lab.py
+++ b/superset/sql_lab.py
@@ -267,7 +267,7 @@ def execute_sql_statement( # pylint: disable=too-many-statements, too-many-loca
if not query.tmp_table_name:
start_dttm = datetime.fromtimestamp(query.start_time)
query.tmp_table_name = (
- f'tmp_{query.user_id}_table_{start_dttm.strftime("%Y_%m_%d_%H_%M_%S")}'
+ f"tmp_{query.user_id}_table_{start_dttm.strftime('%Y_%m_%d_%H_%M_%S')}"
)
sql = parsed_query.as_create_table(
query.tmp_table_name,
diff --git a/superset/sqllab/api.py b/superset/sqllab/api.py
index 2403a36583e..cdb2436e583 100644
--- a/superset/sqllab/api.py
+++ b/superset/sqllab/api.py
@@ -193,7 +193,7 @@ class SqlLabRestApi(BaseSupersetApi):
@protect()
@permission_name("read")
@event_logger.log_this_with_context(
- action=lambda self, *args, **kwargs: f"{self.__class__.__name__}" f".format",
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.format",
log_to_statsd=False,
)
def format_sql(self) -> FlaskResponse:
@@ -238,8 +238,7 @@ class SqlLabRestApi(BaseSupersetApi):
@protect()
@statsd_metrics
@event_logger.log_this_with_context(
- action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
- f".export_csv",
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.export_csv",
log_to_statsd=False,
)
def export_csv(self, client_id: str) -> CsvResponse:
@@ -300,8 +299,7 @@ class SqlLabRestApi(BaseSupersetApi):
@statsd_metrics
@rison(sql_lab_get_results_schema)
@event_logger.log_this_with_context(
- action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
- f".get_results",
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.get_results",
log_to_statsd=False,
)
def get_results(self, **kwargs: Any) -> FlaskResponse:
@@ -355,8 +353,7 @@ class SqlLabRestApi(BaseSupersetApi):
@statsd_metrics
@requires_json
@event_logger.log_this_with_context(
- action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
- f".get_results",
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.get_results",
log_to_statsd=False,
)
def execute_sql_query(self) -> FlaskResponse:
diff --git a/superset/tags/api.py b/superset/tags/api.py
index 7351a39a046..66a22d21eb2 100644
--- a/superset/tags/api.py
+++ b/superset/tags/api.py
@@ -146,8 +146,8 @@ class TagRestApi(BaseSupersetModelRestApi):
"""Deterministic string representation of the API instance for etag_cache."""
return (
"Superset.tags.api.TagRestApi@v"
- f'{self.appbuilder.app.config["VERSION_STRING"]}'
- f'{self.appbuilder.app.config["VERSION_SHA"]}'
+ f"{self.appbuilder.app.config['VERSION_STRING']}"
+ f"{self.appbuilder.app.config['VERSION_SHA']}"
)
@expose("/", methods=("POST",))
@@ -653,8 +653,7 @@ class TagRestApi(BaseSupersetModelRestApi):
@safe
@statsd_metrics
@event_logger.log_this_with_context(
- action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
- f".add_favorite",
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.add_favorite",
log_to_statsd=False,
)
def add_favorite(self, pk: int) -> Response:
diff --git a/superset/utils/core.py b/superset/utils/core.py
index 7dc2270a00e..e3e1a87deca 100644
--- a/superset/utils/core.py
+++ b/superset/utils/core.py
@@ -279,14 +279,14 @@ class QuerySource(Enum):
class QueryStatus(StrEnum):
"""Enum-type class for query statuses"""
- STOPPED: str = "stopped"
- FAILED: str = "failed"
- PENDING: str = "pending"
- RUNNING: str = "running"
- SCHEDULED: str = "scheduled"
- SUCCESS: str = "success"
- FETCHING: str = "fetching"
- TIMED_OUT: str = "timed_out"
+ STOPPED = "stopped"
+ FAILED = "failed"
+ PENDING = "pending"
+ RUNNING = "running"
+ SCHEDULED = "scheduled"
+ SUCCESS = "success"
+ FETCHING = "fetching"
+ TIMED_OUT = "timed_out"
class DashboardStatus(StrEnum):
diff --git a/superset/utils/pandas_postprocessing/histogram.py b/superset/utils/pandas_postprocessing/histogram.py
index 8ef9abadc72..659eac7b42d 100644
--- a/superset/utils/pandas_postprocessing/histogram.py
+++ b/superset/utils/pandas_postprocessing/histogram.py
@@ -60,7 +60,7 @@ def histogram(
# convert the bin edges to strings
bin_edges_str = [
- f"{bin_edges[i]} - {bin_edges[i+1]}" for i in range(len(bin_edges) - 1)
+ f"{bin_edges[i]} - {bin_edges[i + 1]}" for i in range(len(bin_edges) - 1)
]
def hist_values(series: Series) -> np.ndarray:
diff --git a/superset/viz.py b/superset/viz.py
index a42ce942030..d4198071ee1 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -1358,8 +1358,7 @@ class HorizonViz(NVD3TimeSeriesViz):
viz_type = "horizon"
verbose_name = _("Horizon Charts")
credits = (
- ''
- "d3-horizon-chart"
+ 'd3-horizon-chart'
)
diff --git a/tests/integration_tests/celery_tests.py b/tests/integration_tests/celery_tests.py
index 2d060be90ae..050f1e1dc26 100644
--- a/tests/integration_tests/celery_tests.py
+++ b/tests/integration_tests/celery_tests.py
@@ -456,7 +456,7 @@ def test_create_table_as():
assert "CREATE TABLE tmp AS \nSELECT * FROM outer_space" == q.as_create_table("tmp")
# now a multi-line query
- multi_line_query = "SELECT * FROM planets WHERE\n" "Luke_Father = 'Darth Vader'"
+ multi_line_query = "SELECT * FROM planets WHERE\nLuke_Father = 'Darth Vader'"
q = ParsedQuery(multi_line_query)
assert (
"CREATE TABLE tmp AS \nSELECT * FROM planets WHERE\nLuke_Father = 'Darth Vader'"
@@ -473,15 +473,15 @@ def test_in_app_context():
# Expect True within an app context
with app.app_context():
result = my_task.apply().get()
- assert (
- result is True
- ), "Task should have access to current_app within app context"
+ assert result is True, (
+ "Task should have access to current_app within app context"
+ )
# Expect True outside of an app context
result = my_task.apply().get()
- assert (
- result is True
- ), "Task should have access to current_app outside of app context"
+ assert result is True, (
+ "Task should have access to current_app outside of app context"
+ )
def delete_tmp_view_or_table(name: str, db_object_type: str):
diff --git a/tests/integration_tests/conftest.py b/tests/integration_tests/conftest.py
index 08770c16409..5a2af7f04da 100644
--- a/tests/integration_tests/conftest.py
+++ b/tests/integration_tests/conftest.py
@@ -396,7 +396,7 @@ def physical_dataset():
col4 VARCHAR(255),
col5 TIMESTAMP DEFAULT '1970-01-01 00:00:01',
col6 TIMESTAMP DEFAULT '1970-01-01 00:00:01',
- {quoter('time column with spaces')} TIMESTAMP DEFAULT '1970-01-01 00:00:01'
+ {quoter("time column with spaces")} TIMESTAMP DEFAULT '1970-01-01 00:00:01'
);
"""
)
diff --git a/tests/integration_tests/core_tests.py b/tests/integration_tests/core_tests.py
index dc01923e62e..6b28ac13bfd 100644
--- a/tests/integration_tests/core_tests.py
+++ b/tests/integration_tests/core_tests.py
@@ -359,7 +359,7 @@ class TestCore(SupersetTestCase):
def test_fetch_datasource_metadata(self):
self.login(ADMIN_USERNAME)
- url = "/superset/fetch_datasource_metadata?" "datasourceKey=1__table"
+ url = "/superset/fetch_datasource_metadata?datasourceKey=1__table"
resp = self.get_json_resp(url)
keys = [
"name",
diff --git a/tests/integration_tests/dashboards/api_tests.py b/tests/integration_tests/dashboards/api_tests.py
index 430cdf8fe96..56062dc8527 100644
--- a/tests/integration_tests/dashboards/api_tests.py
+++ b/tests/integration_tests/dashboards/api_tests.py
@@ -2437,30 +2437,27 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
response = json.loads(rv.data.decode("utf-8"))
assert rv.status_code == 422
- assert (
- response
- == {
- "errors": [
- {
- "message": "Error importing dashboard",
- "error_type": "GENERIC_COMMAND_ERROR",
- "level": "warning",
- "extra": {
- "dashboards/imported_dashboard.yaml": "Dashboard already exists and `overwrite=true` was not passed", # noqa: E501
- "issue_codes": [
- {
- "code": 1010,
- "message": (
- "Issue 1010 - Superset encountered an "
- "error while running a command."
- ),
- }
- ],
- },
- }
- ]
- }
- )
+ assert response == {
+ "errors": [
+ {
+ "message": "Error importing dashboard",
+ "error_type": "GENERIC_COMMAND_ERROR",
+ "level": "warning",
+ "extra": {
+ "dashboards/imported_dashboard.yaml": "Dashboard already exists and `overwrite=true` was not passed", # noqa: E501
+ "issue_codes": [
+ {
+ "code": 1010,
+ "message": (
+ "Issue 1010 - Superset encountered an "
+ "error while running a command."
+ ),
+ }
+ ],
+ },
+ }
+ ]
+ }
# import with overwrite flag
buf = self.create_dashboard_import()
diff --git a/tests/integration_tests/databases/api_tests.py b/tests/integration_tests/databases/api_tests.py
index 6c34942f61c..03327e0e267 100644
--- a/tests/integration_tests/databases/api_tests.py
+++ b/tests/integration_tests/databases/api_tests.py
@@ -2330,30 +2330,27 @@ class TestDatabaseApi(SupersetTestCase):
response = json.loads(rv.data.decode("utf-8"))
assert rv.status_code == 422
- assert (
- response
- == {
- "errors": [
- {
- "message": "Error importing database",
- "error_type": "GENERIC_COMMAND_ERROR",
- "level": "warning",
- "extra": {
- "databases/imported_database.yaml": "Database already exists and `overwrite=true` was not passed", # noqa: E501
- "issue_codes": [
- {
- "code": 1010,
- "message": (
- "Issue 1010 - Superset encountered an "
- "error while running a command."
- ),
- }
- ],
- },
- }
- ]
- }
- )
+ assert response == {
+ "errors": [
+ {
+ "message": "Error importing database",
+ "error_type": "GENERIC_COMMAND_ERROR",
+ "level": "warning",
+ "extra": {
+ "databases/imported_database.yaml": "Database already exists and `overwrite=true` was not passed", # noqa: E501
+ "issue_codes": [
+ {
+ "code": 1010,
+ "message": (
+ "Issue 1010 - Superset encountered an "
+ "error while running a command."
+ ),
+ }
+ ],
+ },
+ }
+ ]
+ }
# import with overwrite flag
buf = self.create_database_import()
@@ -2681,35 +2678,32 @@ class TestDatabaseApi(SupersetTestCase):
response = json.loads(rv.data.decode("utf-8"))
assert rv.status_code == 422
- assert (
- response
- == {
- "errors": [
- {
- "message": "Error importing database",
- "error_type": "GENERIC_COMMAND_ERROR",
- "level": "warning",
- "extra": {
- "databases/imported_database.yaml": {
- "_schema": [
- "Must provide a private key for the ssh tunnel",
- "Must provide a private key password for the ssh tunnel", # noqa: E501
- ]
- },
- "issue_codes": [
- {
- "code": 1010,
- "message": (
- "Issue 1010 - Superset encountered an "
- "error while running a command."
- ),
- }
- ],
+ assert response == {
+ "errors": [
+ {
+ "message": "Error importing database",
+ "error_type": "GENERIC_COMMAND_ERROR",
+ "level": "warning",
+ "extra": {
+ "databases/imported_database.yaml": {
+ "_schema": [
+ "Must provide a private key for the ssh tunnel",
+ "Must provide a private key password for the ssh tunnel", # noqa: E501
+ ]
},
- }
- ]
- }
- )
+ "issue_codes": [
+ {
+ "code": 1010,
+ "message": (
+ "Issue 1010 - Superset encountered an "
+ "error while running a command."
+ ),
+ }
+ ],
+ },
+ }
+ ]
+ }
@mock.patch("superset.databases.schemas.is_feature_enabled")
@mock.patch("superset.commands.database.importers.v1.utils.add_permissions")
@@ -2976,35 +2970,32 @@ class TestDatabaseApi(SupersetTestCase):
response = json.loads(rv.data.decode("utf-8"))
assert rv.status_code == 422
- assert (
- response
- == {
- "errors": [
- {
- "message": "Error importing database",
- "error_type": "GENERIC_COMMAND_ERROR",
- "level": "warning",
- "extra": {
- "databases/imported_database.yaml": {
- "_schema": [
- "Must provide a private key for the ssh tunnel",
- "Must provide a private key password for the ssh tunnel", # noqa: E501
- ]
- },
- "issue_codes": [
- {
- "code": 1010,
- "message": (
- "Issue 1010 - Superset encountered an "
- "error while running a command."
- ),
- }
- ],
+ assert response == {
+ "errors": [
+ {
+ "message": "Error importing database",
+ "error_type": "GENERIC_COMMAND_ERROR",
+ "level": "warning",
+ "extra": {
+ "databases/imported_database.yaml": {
+ "_schema": [
+ "Must provide a private key for the ssh tunnel",
+ "Must provide a private key password for the ssh tunnel", # noqa: E501
+ ]
},
- }
- ]
- }
- )
+ "issue_codes": [
+ {
+ "code": 1010,
+ "message": (
+ "Issue 1010 - Superset encountered an "
+ "error while running a command."
+ ),
+ }
+ ],
+ },
+ }
+ ]
+ }
@mock.patch(
"superset.db_engine_specs.base.BaseEngineSpec.get_function_names",
diff --git a/tests/integration_tests/datasets/api_tests.py b/tests/integration_tests/datasets/api_tests.py
index 6c6410feed4..4f6aacfca6f 100644
--- a/tests/integration_tests/datasets/api_tests.py
+++ b/tests/integration_tests/datasets/api_tests.py
@@ -866,7 +866,7 @@ class TestDatasetApi(SupersetTestCase):
# cleanup
data = json.loads(rv.data.decode("utf-8"))
- uri = f'api/v1/dataset/{data.get("id")}'
+ uri = f"api/v1/dataset/{data.get('id')}"
rv = self.client.delete(uri)
assert rv.status_code == 200
with example_db.get_sqla_engine() as engine:
@@ -951,7 +951,7 @@ class TestDatasetApi(SupersetTestCase):
# cleanup
data = json.loads(rv.data.decode("utf-8"))
- uri = f'api/v1/dataset/{data.get("id")}'
+ uri = f"api/v1/dataset/{data.get('id')}"
rv = self.client.delete(uri)
assert rv.status_code == 200
diff --git a/tests/integration_tests/datasource_tests.py b/tests/integration_tests/datasource_tests.py
index c3533d131ee..5797d01cc1e 100644
--- a/tests/integration_tests/datasource_tests.py
+++ b/tests/integration_tests/datasource_tests.py
@@ -557,7 +557,7 @@ def test_get_samples(test_client, login_as_admin, virtual_dataset):
sql = (
f"select * from ({virtual_dataset.sql}) as tbl " # noqa: S608
- f'limit {app.config["SAMPLES_ROW_LIMIT"]}'
+ f"limit {app.config['SAMPLES_ROW_LIMIT']}"
)
eager_samples = virtual_dataset.database.get_df(sql)
diff --git a/tests/integration_tests/db_engine_specs/base_engine_spec_tests.py b/tests/integration_tests/db_engine_specs/base_engine_spec_tests.py
index d4d886b67b5..7dd9c5cb95e 100644
--- a/tests/integration_tests/db_engine_specs/base_engine_spec_tests.py
+++ b/tests/integration_tests/db_engine_specs/base_engine_spec_tests.py
@@ -432,8 +432,7 @@ def test_validate_parameters_missing():
assert errors == [
SupersetError(
message=(
- "One or more parameters are missing: "
- "database, host, port, username"
+ "One or more parameters are missing: database, host, port, username"
),
error_type=SupersetErrorType.CONNECTION_MISSING_PARAMETERS_ERROR,
level=ErrorLevel.WARNING,
diff --git a/tests/integration_tests/migrations/7e67aecbf3f1_chart_ds_constraint__tests.py b/tests/integration_tests/migrations/7e67aecbf3f1_chart_ds_constraint__tests.py
index f1772404dc0..cf1d8024bb2 100644
--- a/tests/integration_tests/migrations/7e67aecbf3f1_chart_ds_constraint__tests.py
+++ b/tests/integration_tests/migrations/7e67aecbf3f1_chart_ds_constraint__tests.py
@@ -20,7 +20,7 @@ from importlib import import_module
from superset.utils import json
chart_ds_constraint = import_module(
- "superset.migrations.versions." "2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint",
+ "superset.migrations.versions.2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint",
)
Slice = chart_ds_constraint.Slice
diff --git a/tests/integration_tests/migrations/fb13d49b72f9_better_filters__tests.py b/tests/integration_tests/migrations/fb13d49b72f9_better_filters__tests.py
index b9ccd7c2eb1..b0448415f89 100644
--- a/tests/integration_tests/migrations/fb13d49b72f9_better_filters__tests.py
+++ b/tests/integration_tests/migrations/fb13d49b72f9_better_filters__tests.py
@@ -19,7 +19,7 @@ from importlib import import_module
from superset.utils import json
better_filters = import_module(
- "superset.migrations.versions." "2018-12-11_22-03_fb13d49b72f9_better_filters",
+ "superset.migrations.versions.2018-12-11_22-03_fb13d49b72f9_better_filters",
)
Slice = better_filters.Slice
upgrade_slice = better_filters.upgrade_slice
diff --git a/tests/integration_tests/reports/scheduler_tests.py b/tests/integration_tests/reports/scheduler_tests.py
index 32d91e23ec7..93df88379cf 100644
--- a/tests/integration_tests/reports/scheduler_tests.py
+++ b/tests/integration_tests/reports/scheduler_tests.py
@@ -157,7 +157,7 @@ def test_execute_task(update_state_mock, command_mock, init_mock, owners):
report_schedule = insert_report_schedule(
type=ReportScheduleType.ALERT,
- name=f"report-{randint(0,1000)}", # noqa: S311
+ name=f"report-{randint(0, 1000)}", # noqa: S311
crontab="0 4 * * *",
timezone="America/New_York",
owners=owners,
@@ -184,7 +184,7 @@ def test_execute_task_with_command_exception(
report_schedule = insert_report_schedule(
type=ReportScheduleType.ALERT,
- name=f"report-{randint(0,1000)}", # noqa: S311
+ name=f"report-{randint(0, 1000)}", # noqa: S311
crontab="0 4 * * *",
timezone="America/New_York",
owners=owners,
diff --git a/tests/integration_tests/sql_lab/commands_tests.py b/tests/integration_tests/sql_lab/commands_tests.py
index acd9edbf21e..4163b58b7a4 100644
--- a/tests/integration_tests/sql_lab/commands_tests.py
+++ b/tests/integration_tests/sql_lab/commands_tests.py
@@ -86,13 +86,10 @@ class TestQueryEstimationCommand(SupersetTestCase):
assert (
ex_info.value.error.error_type == SupersetErrorType.SQLLAB_TIMEOUT_ERROR
)
- assert (
- ex_info.value.error.message
- == __(
- "The query estimation was killed after %(sqllab_timeout)s seconds. It might " # noqa: E501
- "be too complex, or the database might be under heavy load.",
- sqllab_timeout=app.config["SQLLAB_QUERY_COST_ESTIMATE_TIMEOUT"],
- )
+ assert ex_info.value.error.message == __(
+ "The query estimation was killed after %(sqllab_timeout)s seconds. It might " # noqa: E501
+ "be too complex, or the database might be under heavy load.",
+ sqllab_timeout=app.config["SQLLAB_QUERY_COST_ESTIMATE_TIMEOUT"],
)
def test_run_success(self) -> None:
diff --git a/tests/integration_tests/sqllab_tests.py b/tests/integration_tests/sqllab_tests.py
index 65d0c5fd3bd..514053f7d1e 100644
--- a/tests/integration_tests/sqllab_tests.py
+++ b/tests/integration_tests/sqllab_tests.py
@@ -132,30 +132,27 @@ class TestSqlLab(SupersetTestCase):
self.login(ADMIN_USERNAME)
data = self.run_sql("DELETE FROM birth_names", "1")
- assert (
- data
- == {
- "errors": [
- {
- "message": (
- "This database does not allow for DDL/DML, and the query "
- "could not be parsed to confirm it is a read-only query. Please " # noqa: E501
- "contact your administrator for more assistance."
- ),
- "error_type": SupersetErrorType.DML_NOT_ALLOWED_ERROR,
- "level": ErrorLevel.ERROR,
- "extra": {
- "issue_codes": [
- {
- "code": 1022,
- "message": "Issue 1022 - Database does not allow data manipulation.", # noqa: E501
- }
- ]
- },
- }
- ]
- }
- )
+ assert data == {
+ "errors": [
+ {
+ "message": (
+ "This database does not allow for DDL/DML, and the query "
+ "could not be parsed to confirm it is a read-only query. Please " # noqa: E501
+ "contact your administrator for more assistance."
+ ),
+ "error_type": SupersetErrorType.DML_NOT_ALLOWED_ERROR,
+ "level": ErrorLevel.ERROR,
+ "extra": {
+ "issue_codes": [
+ {
+ "code": 1022,
+ "message": "Issue 1022 - Database does not allow data manipulation.", # noqa: E501
+ }
+ ]
+ },
+ }
+ ]
+ }
@parameterized.expand([CtasMethod.TABLE, CtasMethod.VIEW])
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
@@ -848,33 +845,30 @@ class TestSqlLab(SupersetTestCase):
handle_cursor.side_effect = SoftTimeLimitExceeded()
data = self.run_sql("SELECT * FROM birth_names LIMIT 1", "1")
- assert (
- data
- == {
- "errors": [
- {
- "message": (
- "The query was killed after 21600 seconds. It might be too complex, " # noqa: E501
- "or the database might be under heavy load."
- ),
- "error_type": SupersetErrorType.SQLLAB_TIMEOUT_ERROR,
- "level": ErrorLevel.ERROR,
- "extra": {
- "issue_codes": [
- {
- "code": 1026,
- "message": "Issue 1026 - Query is too complex and takes too long to run.", # noqa: E501
- },
- {
- "code": 1027,
- "message": "Issue 1027 - The database is currently running too many queries.", # noqa: E501
- },
- ]
- },
- }
- ]
- }
- )
+ assert data == {
+ "errors": [
+ {
+ "message": (
+ "The query was killed after 21600 seconds. It might be too complex, " # noqa: E501
+ "or the database might be under heavy load."
+ ),
+ "error_type": SupersetErrorType.SQLLAB_TIMEOUT_ERROR,
+ "level": ErrorLevel.ERROR,
+ "extra": {
+ "issue_codes": [
+ {
+ "code": 1026,
+ "message": "Issue 1026 - Query is too complex and takes too long to run.", # noqa: E501
+ },
+ {
+ "code": 1027,
+ "message": "Issue 1027 - The database is currently running too many queries.", # noqa: E501
+ },
+ ]
+ },
+ }
+ ]
+ }
def test_apply_limit_if_exists_when_incremented_limit_is_none(self):
sql = """
diff --git a/tests/integration_tests/tags/api_tests.py b/tests/integration_tests/tags/api_tests.py
index 79022d2805e..7f65c862a4b 100644
--- a/tests/integration_tests/tags/api_tests.py
+++ b/tests/integration_tests/tags/api_tests.py
@@ -359,7 +359,7 @@ class TestTagApi(SupersetTestCase):
TaggedObject.object_type == dashboard_type.name,
)
assert tagged_objects.count() == 2
- uri = f'api/v1/tag/get_objects/?tags={",".join(tag_names)}'
+ uri = f"api/v1/tag/get_objects/?tags={','.join(tag_names)}"
rv = self.client.get(uri)
# successful request
assert rv.status_code == 200
diff --git a/tests/unit_tests/commands/databases/excel_reader_test.py b/tests/unit_tests/commands/databases/excel_reader_test.py
index 5f4ebca2c32..384dfab93a1 100644
--- a/tests/unit_tests/commands/databases/excel_reader_test.py
+++ b/tests/unit_tests/commands/databases/excel_reader_test.py
@@ -226,7 +226,7 @@ def test_excel_reader_wrong_date():
with pytest.raises(DatabaseUploadFailed) as ex:
excel_reader.file_to_dataframe(create_excel_file(EXCEL_DATA))
assert str(ex.value) == (
- "Parsing error: Missing column provided to 'parse_dates':" " 'xpto' (sheet: 0)"
+ "Parsing error: Missing column provided to 'parse_dates': 'xpto' (sheet: 0)"
)
diff --git a/tests/unit_tests/connectors/sqla/models_test.py b/tests/unit_tests/connectors/sqla/models_test.py
index 5820e5fa378..8e1523585f7 100644
--- a/tests/unit_tests/connectors/sqla/models_test.py
+++ b/tests/unit_tests/connectors/sqla/models_test.py
@@ -187,13 +187,10 @@ def test_query_datasources_by_permissions_with_catalog_schema(
["[my_db].[db1].[schema1]", "[my_other_db].[schema]"], # type: ignore
)
clause = db.session.query().filter_by().filter.mock_calls[0].args[0]
- assert (
- str(clause.compile(engine, compile_kwargs={"literal_binds": True}))
- == (
- "tables.perm IN ('[my_db].[table1](id:1)') OR "
- "tables.schema_perm IN ('[my_db].[db1].[schema1]', '[my_other_db].[schema]') OR " # noqa: E501
- "tables.catalog_perm IN ('[my_db].[db1]')"
- )
+ assert str(clause.compile(engine, compile_kwargs={"literal_binds": True})) == (
+ "tables.perm IN ('[my_db].[table1](id:1)') OR "
+ "tables.schema_perm IN ('[my_db].[db1].[schema1]', '[my_other_db].[schema]') OR " # noqa: E501
+ "tables.catalog_perm IN ('[my_db].[db1]')"
)
diff --git a/tests/unit_tests/datasets/api_tests.py b/tests/unit_tests/datasets/api_tests.py
index e0786afaa3b..5296c1bba2a 100644
--- a/tests/unit_tests/datasets/api_tests.py
+++ b/tests/unit_tests/datasets/api_tests.py
@@ -64,8 +64,7 @@ def test_put_invalid_dataset(
{
"code": 1040,
"message": (
- "Issue 1040 - The submitted payload "
- "failed validation."
+ "Issue 1040 - The submitted payload failed validation."
),
}
],
diff --git a/tests/unit_tests/datasets/commands/export_test.py b/tests/unit_tests/datasets/commands/export_test.py
index 0b5bae310a4..f42bbfc9cbb 100644
--- a/tests/unit_tests/datasets/commands/export_test.py
+++ b/tests/unit_tests/datasets/commands/export_test.py
@@ -126,7 +126,7 @@ extra:
warning_markdown: '*WARNING*'
normalize_columns: false
always_filter_main_dttm: false
-uuid: {payload['uuid']}
+uuid: {payload["uuid"]}
metrics:
- metric_name: cnt
verbose_name: null
diff --git a/tests/unit_tests/db_engine_specs/test_gsheets.py b/tests/unit_tests/db_engine_specs/test_gsheets.py
index 5405f742022..df05c513120 100644
--- a/tests/unit_tests/db_engine_specs/test_gsheets.py
+++ b/tests/unit_tests/db_engine_specs/test_gsheets.py
@@ -120,61 +120,58 @@ def test_validate_parameters_catalog(
}
errors = GSheetsEngineSpec.validate_parameters(properties) # ignore: type
- assert (
- errors
- == [
- SupersetError(
- message=(
- "The URL could not be identified. Please check for typos "
- "and make sure that ‘Type of Google Sheets allowed’ "
- "selection matches the input."
- ),
- error_type=SupersetErrorType.TABLE_DOES_NOT_EXIST_ERROR,
- level=ErrorLevel.WARNING,
- extra={
- "catalog": {
- "idx": 0,
- "url": True,
- },
- "issue_codes": [
- {
- "code": 1003,
- "message": "Issue 1003 - There is a syntax error in the SQL query. Perhaps there was a misspelling or a typo.", # noqa: E501
- },
- {
- "code": 1005,
- "message": "Issue 1005 - The table was deleted or renamed in the database.", # noqa: E501
- },
- ],
- },
+ assert errors == [
+ SupersetError(
+ message=(
+ "The URL could not be identified. Please check for typos "
+ "and make sure that ‘Type of Google Sheets allowed’ "
+ "selection matches the input."
),
- SupersetError(
- message=(
- "The URL could not be identified. Please check for typos "
- "and make sure that ‘Type of Google Sheets allowed’ "
- "selection matches the input."
- ),
- error_type=SupersetErrorType.TABLE_DOES_NOT_EXIST_ERROR,
- level=ErrorLevel.WARNING,
- extra={
- "catalog": {
- "idx": 2,
- "url": True,
- },
- "issue_codes": [
- {
- "code": 1003,
- "message": "Issue 1003 - There is a syntax error in the SQL query. Perhaps there was a misspelling or a typo.", # noqa: E501
- },
- {
- "code": 1005,
- "message": "Issue 1005 - The table was deleted or renamed in the database.", # noqa: E501
- },
- ],
+ error_type=SupersetErrorType.TABLE_DOES_NOT_EXIST_ERROR,
+ level=ErrorLevel.WARNING,
+ extra={
+ "catalog": {
+ "idx": 0,
+ "url": True,
},
+ "issue_codes": [
+ {
+ "code": 1003,
+ "message": "Issue 1003 - There is a syntax error in the SQL query. Perhaps there was a misspelling or a typo.", # noqa: E501
+ },
+ {
+ "code": 1005,
+ "message": "Issue 1005 - The table was deleted or renamed in the database.", # noqa: E501
+ },
+ ],
+ },
+ ),
+ SupersetError(
+ message=(
+ "The URL could not be identified. Please check for typos "
+ "and make sure that ‘Type of Google Sheets allowed’ "
+ "selection matches the input."
),
- ]
- )
+ error_type=SupersetErrorType.TABLE_DOES_NOT_EXIST_ERROR,
+ level=ErrorLevel.WARNING,
+ extra={
+ "catalog": {
+ "idx": 2,
+ "url": True,
+ },
+ "issue_codes": [
+ {
+ "code": 1003,
+ "message": "Issue 1003 - There is a syntax error in the SQL query. Perhaps there was a misspelling or a typo.", # noqa: E501
+ },
+ {
+ "code": 1005,
+ "message": "Issue 1005 - The table was deleted or renamed in the database.", # noqa: E501
+ },
+ ],
+ },
+ ),
+ ]
create_engine.assert_called_with(
"gsheets://",
diff --git a/tests/unit_tests/db_engine_specs/test_mssql.py b/tests/unit_tests/db_engine_specs/test_mssql.py
index affd758f091..35fa91108ab 100644
--- a/tests/unit_tests/db_engine_specs/test_mssql.py
+++ b/tests/unit_tests/db_engine_specs/test_mssql.py
@@ -420,31 +420,28 @@ Adaptive Server connection failed (mssqldb.cxiotftzsypc.us-west-2.rds.amazonaws.
result = MssqlEngineSpec.extract_errors(
Exception(msg), context={"username": "testuser", "database": "testdb"}
)
- assert (
- result
- == [
- SupersetError(
- message='Either the username "testuser", password, or database name "testdb" is incorrect.', # noqa: E501
- error_type=SupersetErrorType.CONNECTION_ACCESS_DENIED_ERROR,
- level=ErrorLevel.ERROR,
- extra={
- "engine_name": "Microsoft SQL Server",
- "issue_codes": [
- {
- "code": 1014,
- "message": "Issue 1014 - Either the username or "
- "the password is wrong.",
- },
- {
- "code": 1015,
- "message": "Issue 1015 - Either the database is "
- "spelled incorrectly or does not exist.",
- },
- ],
- },
- )
- ]
- )
+ assert result == [
+ SupersetError(
+ message='Either the username "testuser", password, or database name "testdb" is incorrect.', # noqa: E501
+ error_type=SupersetErrorType.CONNECTION_ACCESS_DENIED_ERROR,
+ level=ErrorLevel.ERROR,
+ extra={
+ "engine_name": "Microsoft SQL Server",
+ "issue_codes": [
+ {
+ "code": 1014,
+ "message": "Issue 1014 - Either the username or "
+ "the password is wrong.",
+ },
+ {
+ "code": 1015,
+ "message": "Issue 1015 - Either the database is "
+ "spelled incorrectly or does not exist.",
+ },
+ ],
+ },
+ )
+ ]
@pytest.mark.parametrize(
diff --git a/tests/unit_tests/db_engine_specs/test_ocient.py b/tests/unit_tests/db_engine_specs/test_ocient.py
index 445a118b7be..82c7c206bfc 100644
--- a/tests/unit_tests/db_engine_specs/test_ocient.py
+++ b/tests/unit_tests/db_engine_specs/test_ocient.py
@@ -223,9 +223,9 @@ def test_connection_errors(msg: str, expected: SupersetError) -> None:
assert result == [expected]
-def _generate_gis_type_sanitization_test_cases() -> (
- list[tuple[str, int, Any, dict[str, Any]]]
-):
+def _generate_gis_type_sanitization_test_cases() -> list[
+ tuple[str, int, Any, dict[str, Any]]
+]:
if not ocient_is_installed():
return []
diff --git a/tests/unit_tests/fixtures/dataframes.py b/tests/unit_tests/fixtures/dataframes.py
index 7e09938397e..34ccfe01e01 100644
--- a/tests/unit_tests/fixtures/dataframes.py
+++ b/tests/unit_tests/fixtures/dataframes.py
@@ -116,8 +116,8 @@ names_df = DataFrame(
categories_df = DataFrame(
{
"constant": ["dummy" for _ in range(0, 101)],
- "category": [f"cat{i%3}" for i in range(0, 101)],
- "dept": [f"dept{i%5}" for i in range(0, 101)],
+ "category": [f"cat{i % 3}" for i in range(0, 101)],
+ "dept": [f"dept{i % 5}" for i in range(0, 101)],
"name": [f"person{i}" for i in range(0, 101)],
"asc_idx": [i for i in range(0, 101)], # noqa: C416
"desc_idx": [i for i in range(100, -1, -1)], # noqa: C416
|