style: enforcing mypy typing for connectors (#9824)

Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
John Bodley
2020-05-25 12:32:49 -07:00
committed by GitHub
parent 9edfc8f68d
commit 7f6dbf838e
17 changed files with 392 additions and 240 deletions

View File

@@ -15,15 +15,22 @@
# specific language governing permissions and limitations
# under the License.
import logging
from typing import Callable, Optional
from flask_appbuilder import Model
from sqlalchemy.orm import Session
from sqlalchemy.orm.session import make_transient
logger = logging.getLogger(__name__)
def import_datasource(
session, i_datasource, lookup_database, lookup_datasource, import_time
):
session: Session,
i_datasource: Model,
lookup_database: Callable,
lookup_datasource: Callable,
import_time: Optional[int] = None,
) -> int:
"""Imports the datasource from the object to the database.
Metrics and columns and datasource will be overrided if exists.
@@ -75,7 +82,7 @@ def import_datasource(
return datasource.id
def import_simple_obj(session, i_obj, lookup_obj):
def import_simple_obj(session: Session, i_obj: Model, lookup_obj: Callable) -> Model:
make_transient(i_obj)
i_obj.id = None
i_obj.table = None