From 7cd38588f6d1d456928f9441943e3aaff35ce7b1 Mon Sep 17 00:00:00 2001 From: Kasia Kucharczyk Date: Mon, 21 Sep 2020 18:07:31 +0200 Subject: [PATCH 1/9] Athena.py: cretaed variable for too long line, removed disabled pylint rule. --- superset/db_engine_specs/athena.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/superset/db_engine_specs/athena.py b/superset/db_engine_specs/athena.py index 91e1069ff68b2..4b810e1e5f814 100644 --- a/superset/db_engine_specs/athena.py +++ b/superset/db_engine_specs/athena.py @@ -47,7 +47,8 @@ def convert_dttm(cls, target_type: str, dttm: datetime) -> Optional[str]: if tt == utils.TemporalType.DATE: return f"from_iso8601_date('{dttm.date().isoformat()}')" if tt == utils.TemporalType.TIMESTAMP: - return f"""from_iso8601_timestamp('{dttm.isoformat(timespec="microseconds")}')""" # pylint: disable=line-too-long + datetime_formatted = dttm.isoformat(timespec="microseconds") + return f"""from_iso8601_timestamp('{datetime_formatted}') """ return None @classmethod From 5f88379e5919d713c6510749dd76a51f9538ac5d Mon Sep 17 00:00:00 2001 From: Kasia Kucharczyk Date: Mon, 21 Sep 2020 18:16:59 +0200 Subject: [PATCH 2/9] Enabled `line-too-long` in `drill.py`. Added variable for too long string. --- superset/db_engine_specs/drill.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/superset/db_engine_specs/drill.py b/superset/db_engine_specs/drill.py index 7406d654cbe9f..fc3d833cfffbb 100644 --- a/superset/db_engine_specs/drill.py +++ b/superset/db_engine_specs/drill.py @@ -59,7 +59,8 @@ def convert_dttm(cls, target_type: str, dttm: datetime) -> Optional[str]: if tt == utils.TemporalType.DATE: return f"TO_DATE('{dttm.date().isoformat()}', 'yyyy-MM-dd')" if tt == utils.TemporalType.TIMESTAMP: - return f"""TO_TIMESTAMP('{dttm.isoformat(sep=" ", timespec="seconds")}', 'yyyy-MM-dd HH:mm:ss')""" # pylint: disable=line-too-long + datetime_formatted = dttm.isoformat(sep=" ", timespec="seconds") + return f"""TO_TIMESTAMP('{datetime_formatted}', 'yyyy-MM-dd HH:mm:ss')""" return None @classmethod From 902d90bdadb8a506c66ec4018ceba94e089f6927 Mon Sep 17 00:00:00 2001 From: Kasia Kucharczyk Date: Mon, 21 Sep 2020 18:34:09 +0200 Subject: [PATCH 3/9] Reformatted hana.py: - changed return statement into two lines to keep line lenght limit --- superset/db_engine_specs/hana.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/superset/db_engine_specs/hana.py b/superset/db_engine_specs/hana.py index c4b157a624904..11e49d1896ab2 100644 --- a/superset/db_engine_specs/hana.py +++ b/superset/db_engine_specs/hana.py @@ -48,5 +48,6 @@ def convert_dttm(cls, target_type: str, dttm: datetime) -> Optional[str]: if tt == utils.TemporalType.DATE: return f"TO_DATE('{dttm.date().isoformat()}', 'YYYY-MM-DD')" if tt == utils.TemporalType.TIMESTAMP: - return f"""TO_TIMESTAMP('{dttm.isoformat(timespec="microseconds")}', 'YYYY-MM-DD"T"HH24:MI:SS.ff6')""" # pylint: disable=line-too-long + return f"""TO_TIMESTAMP('{dttm + .isoformat(timespec="microseconds")}', 'YYYY-MM-DD"T"HH24:MI:SS.ff6')""" return None From 56d475960ce7fc57bb2623a20886daaeaffdec60 Mon Sep 17 00:00:00 2001 From: Kasia Kucharczyk Date: Mon, 21 Sep 2020 18:47:36 +0200 Subject: [PATCH 4/9] Enabling pylint rule in hive.py: - `no-name-in-module` for pyhive in several places - `line-too-long` and adding new lines - `unused-import` is not invalid anymore --- superset/db_engine_specs/hive.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/superset/db_engine_specs/hive.py b/superset/db_engine_specs/hive.py index 918128fa4f9f7..c762848cad3cb 100644 --- a/superset/db_engine_specs/hive.py +++ b/superset/db_engine_specs/hive.py @@ -41,7 +41,7 @@ if TYPE_CHECKING: # prevent circular imports - from superset.models.core import Database # pylint: disable=unused-import + from superset.models.core import Database QueryStatus = utils.QueryStatus config = app.config @@ -111,7 +111,7 @@ class HiveEngineSpec(PrestoEngineSpec): @classmethod def patch(cls) -> None: - from pyhive import hive # pylint: disable=no-name-in-module + from pyhive import hive from TCLIService import ( constants as patched_constants, TCLIService as patched_TCLIService, @@ -263,7 +263,8 @@ def convert_dttm(cls, target_type: str, dttm: datetime) -> Optional[str]: if tt == utils.TemporalType.DATE: return f"CAST('{dttm.date().isoformat()}' AS DATE)" if tt == utils.TemporalType.TIMESTAMP: - return f"""CAST('{dttm.isoformat(sep=" ", timespec="microseconds")}' AS TIMESTAMP)""" # pylint: disable=line-too-long + return f"""CAST('{dttm + .isoformat(sep=" ", timespec="microseconds")}' AS TIMESTAMP)""" return None @classmethod @@ -325,7 +326,7 @@ def handle_cursor( # pylint: disable=too-many-locals cls, cursor: Any, query: Query, session: Session ) -> None: """Updates progress information""" - from pyhive import hive # pylint: disable=no-name-in-module + from pyhive import hive unfinished_states = ( hive.ttypes.TOperationState.INITIALIZED_STATE, From a8c83f7b84584341e348c58c1357c4d79a5888d6 Mon Sep 17 00:00:00 2001 From: Kasia Kucharczyk Date: Tue, 22 Sep 2020 10:17:47 +0200 Subject: [PATCH 5/9] Enabled `line-too-long` in `kylin.py`. Added variable for too long string. --- superset/db_engine_specs/kylin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/superset/db_engine_specs/kylin.py b/superset/db_engine_specs/kylin.py index 4a64091d155db..53c45c6a2ba60 100644 --- a/superset/db_engine_specs/kylin.py +++ b/superset/db_engine_specs/kylin.py @@ -47,5 +47,6 @@ def convert_dttm(cls, target_type: str, dttm: datetime) -> Optional[str]: if tt == utils.TemporalType.DATE: return f"CAST('{dttm.date().isoformat()}' AS DATE)" if tt == utils.TemporalType.TIMESTAMP: - return f"""CAST('{dttm.isoformat(sep=" ", timespec="seconds")}' AS TIMESTAMP)""" # pylint: disable=line-too-long + datetime_fomatted = dttm.isoformat(sep=" ", timespec="seconds") + return f"""CAST('{datetime_fomatted}' AS TIMESTAMP)""" return None From 36e1f264f02c514e7bdb6e8589cf4c09c81e6e93 Mon Sep 17 00:00:00 2001 From: Kasia Kucharczyk Date: Tue, 22 Sep 2020 12:44:02 +0200 Subject: [PATCH 6/9] Enabled `unused_import` in `base.py` from db_engine_specs module. --- superset/db_engine_specs/base.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/superset/db_engine_specs/base.py b/superset/db_engine_specs/base.py index f924ade58e072..de99f6e676b8c 100644 --- a/superset/db_engine_specs/base.py +++ b/superset/db_engine_specs/base.py @@ -59,10 +59,8 @@ if TYPE_CHECKING: # prevent circular imports - from superset.connectors.sqla.models import ( # pylint: disable=unused-import - TableColumn, - ) - from superset.models.core import Database # pylint: disable=unused-import + from superset.connectors.sqla.models import TableColumn + from superset.models.core import Database logger = logging.getLogger() From 1ed87c673e23f79ffa673a9ac56935b13d28d7a0 Mon Sep 17 00:00:00 2001 From: Kasia Kucharczyk Date: Tue, 22 Sep 2020 12:45:17 +0200 Subject: [PATCH 7/9] Enabled `unused_import` in `bigquery.py` from db_engine_specs module. --- superset/db_engine_specs/bigquery.py | 1 - 1 file changed, 1 deletion(-) diff --git a/superset/db_engine_specs/bigquery.py b/superset/db_engine_specs/bigquery.py index 71ae8280bc012..1a111cd3bf0e3 100644 --- a/superset/db_engine_specs/bigquery.py +++ b/superset/db_engine_specs/bigquery.py @@ -27,7 +27,6 @@ from superset.utils import core as utils if TYPE_CHECKING: - # pylint: disable=unused-import from superset.models.core import Database # pragma: no cover From 8d9efbe01b7cb12d2585be5f1e24908c63504b5d Mon Sep 17 00:00:00 2001 From: Kasia Kucharczyk Date: Tue, 22 Sep 2020 12:46:16 +0200 Subject: [PATCH 8/9] Enabled `unused_import` in `druid.py` from db_engine_specs module. --- superset/db_engine_specs/druid.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/superset/db_engine_specs/druid.py b/superset/db_engine_specs/druid.py index f941fd1bad7b0..1a774983987c9 100644 --- a/superset/db_engine_specs/druid.py +++ b/superset/db_engine_specs/druid.py @@ -23,10 +23,8 @@ from superset.utils import core as utils if TYPE_CHECKING: - from superset.connectors.sqla.models import ( # pylint: disable=unused-import - TableColumn, - ) - from superset.models.core import Database # pylint: disable=unused-import + from superset.connectors.sqla.models import TableColumn + from superset.models.core import Database logger = logging.getLogger() From 5c0f2c9edbbe166915c61a015523671de57b6b34 Mon Sep 17 00:00:00 2001 From: Kasia Kucharczyk Date: Tue, 22 Sep 2020 13:26:37 +0200 Subject: [PATCH 9/9] fix: athena datetime string converting --- superset/db_engine_specs/athena.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset/db_engine_specs/athena.py b/superset/db_engine_specs/athena.py index 4b810e1e5f814..d82591756a003 100644 --- a/superset/db_engine_specs/athena.py +++ b/superset/db_engine_specs/athena.py @@ -48,7 +48,7 @@ def convert_dttm(cls, target_type: str, dttm: datetime) -> Optional[str]: return f"from_iso8601_date('{dttm.date().isoformat()}')" if tt == utils.TemporalType.TIMESTAMP: datetime_formatted = dttm.isoformat(timespec="microseconds") - return f"""from_iso8601_timestamp('{datetime_formatted}') """ + return f"""from_iso8601_timestamp('{datetime_formatted}')""" return None @classmethod