This is an automated email from the ASF dual-hosted git repository. potiuk pushed a commit to branch v1-10-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit b658468aae77c1f19ef11ed8c4108ca7adebdb10 Author: Qingping Hou <[email protected]> AuthorDate: Wed Nov 13 01:28:53 2019 -0800 [AIRFLOW-5898] fix alembic crash due to typing import (#6547) (cherry picked from commit 3a3730eaa5ff1b6ca25a510bd7fb6894f8965bc3) --- airflow/bin/cli.py | 2 +- airflow/serialization/json_schema.py | 2 +- airflow/typing_compat.py | 30 ++++++++++++++++++++++++++++++ docs/conf.py | 1 + 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/airflow/bin/cli.py b/airflow/bin/cli.py index eec216e..e70ccdd 100644 --- a/airflow/bin/cli.py +++ b/airflow/bin/cli.py @@ -58,7 +58,6 @@ import time import traceback from typing import Any -from typing_extensions import Protocol import airflow from airflow import api @@ -70,6 +69,7 @@ from airflow.models import ( Connection, DagModel, DagBag, DagPickle, TaskInstance, DagRun, Variable, DAG ) from airflow.ti_deps.dep_context import (DepContext, SCHEDULER_QUEUED_DEPS) +from airflow.typing_compat import Protocol from airflow.utils import cli as cli_utils, db from airflow.utils.dot_renderer import render_dag from airflow.utils.net import get_hostname diff --git a/airflow/serialization/json_schema.py b/airflow/serialization/json_schema.py index e33ce8c..3ea56af 100644 --- a/airflow/serialization/json_schema.py +++ b/airflow/serialization/json_schema.py @@ -23,10 +23,10 @@ import pkgutil from typing import Iterable import jsonschema -from typing_extensions import Protocol from airflow.exceptions import AirflowException from airflow.settings import json +from airflow.typing_compat import Protocol class Validator(Protocol): diff --git a/airflow/typing_compat.py b/airflow/typing_compat.py new file mode 100644 index 0000000..f4ed7bd --- /dev/null +++ b/airflow/typing_compat.py @@ -0,0 +1,30 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +""" +This module provides helper code to make type annotation within Airflow +codebase easier. +""" + +try: + # Protocol is only added to typing module starting from python 3.8 + # we can safely remove this shim import after Airflow drops support for + # <3.8 + from typing import Protocol # noqa # pylint: disable=unused-import +except ImportError: + from typing_extensions import Protocol # type: ignore # noqa diff --git a/docs/conf.py b/docs/conf.py index 5f2a113..8eeb3b5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -211,6 +211,7 @@ exclude_patterns = [ '_api/airflow/sentry', '_api/airflow/stats', '_api/airflow/task', + '_api/airflow/typing_compat', '_api/airflow/kubernetes', '_api/airflow/ti_deps', '_api/airflow/utils',
