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

fix: enable pylint rules in db_engine_specs module #10998

Merged
merged 9 commits into from
Sep 22, 2020
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