Skip to content

Commit

Permalink
fix: enable pylint rules in db_engine_specs module (#10998)
Browse files Browse the repository at this point in the history
* Athena.py: cretaed variable for too long line, removed disabled pylint rule.

* Enabled `line-too-long` in `drill.py`. Added variable for too long string.

* Reformatted hana.py:
- changed return statement into two lines to keep line lenght limit

* 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

* Enabled `line-too-long` in `kylin.py`. Added variable for too long string.

* Enabled `unused_import` in `base.py` from db_engine_specs module.

* Enabled `unused_import` in `bigquery.py` from db_engine_specs module.

* Enabled `unused_import` in `druid.py` from db_engine_specs module.

* fix: athena datetime string converting
  • Loading branch information
kkucharc authored Sep 22, 2020
1 parent e93d92e commit a6f2587
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
3 changes: 2 additions & 1 deletion superset/db_engine_specs/athena.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions superset/db_engine_specs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
1 change: 0 additions & 1 deletion superset/db_engine_specs/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
3 changes: 2 additions & 1 deletion superset/db_engine_specs/drill.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions superset/db_engine_specs/druid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 2 additions & 1 deletion superset/db_engine_specs/hana.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 5 additions & 4 deletions superset/db_engine_specs/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion superset/db_engine_specs/kylin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a6f2587

Please sign in to comment.