You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2020/06/26 20:26:04 UTC
[airflow] branch v1-10-test updated: [AIRFLOW-5898] fix alembic
crash due to typing import (#6547)
This is an automated email from the ASF dual-hosted git repository.
kaxilnaik pushed a commit to branch v1-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v1-10-test by this push:
new 3f8b5bf [AIRFLOW-5898] fix alembic crash due to typing import (#6547)
3f8b5bf is described below
commit 3f8b5bf437ee148d62d8a265b1f85d8c4d800efe
Author: Qingping Hou <qp...@scribd.com>
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',