chore(pylint): Reenable import-outside-toplevel check (#16263)

Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
John Bodley
2021-08-16 10:20:13 -07:00
committed by GitHub
parent 36abc51f90
commit 0df15bf207
25 changed files with 83 additions and 51 deletions

View File

@@ -324,6 +324,7 @@ class BigQueryEngineSpec(BaseEngineSpec):
"""
try:
# pylint: disable=import-outside-toplevel
import pandas_gbq
from google.oauth2 import service_account
except ImportError:

View File

@@ -17,6 +17,8 @@
from datetime import datetime
from typing import Dict, Optional, Type
from urllib3.exceptions import NewConnectionError
from superset.db_engine_specs.base import BaseEngineSpec
from superset.db_engine_specs.exceptions import SupersetDBAPIDatabaseError
from superset.utils import core as utils
@@ -48,8 +50,6 @@ class ClickHouseEngineSpec(BaseEngineSpec): # pylint: disable=abstract-method
@classmethod
def get_dbapi_exception_mapping(cls) -> Dict[Type[Exception], Type[Exception]]:
from urllib3.exceptions import NewConnectionError
return {NewConnectionError: SupersetDBAPIDatabaseError}
@classmethod

View File

@@ -49,7 +49,8 @@ class ElasticSearchEngineSpec(BaseEngineSpec): # pylint: disable=abstract-metho
@classmethod
def get_dbapi_exception_mapping(cls) -> Dict[Type[Exception], Type[Exception]]:
import es.exceptions as es_exceptions # pylint: disable=import-error
# pylint: disable=import-error,import-outside-toplevel
import es.exceptions as es_exceptions
return {
es_exceptions.DatabaseError: SupersetDBAPIDatabaseError,

View File

@@ -62,8 +62,8 @@ def upload_to_s3(filename: str, upload_prefix: str, table: Table) -> str:
:returns: The S3 location of the table
"""
# Optional dependency
import boto3 # pylint: disable=import-error
# pylint: disable=import-outside-toplevel
import boto3
bucket_path = current_app.config["CSV_TO_HIVE_UPLOAD_S3_BUCKET"]
@@ -128,6 +128,7 @@ class HiveEngineSpec(PrestoEngineSpec):
@classmethod
def patch(cls) -> None:
# pylint: disable=import-outside-toplevel
from pyhive import hive
from TCLIService import (
constants as patched_constants,
@@ -152,6 +153,7 @@ class HiveEngineSpec(PrestoEngineSpec):
def fetch_data(
cls, cursor: Any, limit: Optional[int] = None
) -> List[Tuple[Any, ...]]:
# pylint: disable=import-outside-toplevel
import pyhive
from TCLIService import ttypes
@@ -314,6 +316,7 @@ class HiveEngineSpec(PrestoEngineSpec):
cls, cursor: Any, query: Query, session: Session
) -> None:
"""Updates progress information"""
# pylint: disable=import-outside-toplevel
from pyhive import hive
unfinished_states = (

View File

@@ -171,6 +171,7 @@ class MySQLEngineSpec(BaseEngineSpec, BasicParametersMixin):
def get_datatype(cls, type_code: Any) -> Optional[str]:
if not cls.type_code_map:
# only import and store if needed at least once
# pylint: disable=import-outside-toplevel
import MySQLdb
ft = MySQLdb.constants.FIELD_TYPE

View File

@@ -925,6 +925,7 @@ class PrestoEngineSpec(BaseEngineSpec): # pylint: disable=too-many-public-metho
:param schema: Schema name
:param table: Table (view) name
"""
# pylint: disable=import-outside-toplevel
from pyhive.exc import DatabaseError
engine = cls.get_engine(database, schema)