From 573ef53cd44e73be85d0baf020d03969d5a9e812 Mon Sep 17 00:00:00 2001 From: Ryan Hamilton Date: Thu, 4 Feb 2021 12:07:15 -0500 Subject: [PATCH] Refactor redundant doc url logic to use utility --- airflow/api_connexion/exceptions.py | 12 +++--------- airflow/utils/docs.py | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/airflow/api_connexion/exceptions.py b/airflow/api_connexion/exceptions.py index 7bfd06f39e87c3..194bfdb36fe511 100644 --- a/airflow/api_connexion/exceptions.py +++ b/airflow/api_connexion/exceptions.py @@ -19,15 +19,9 @@ import werkzeug from connexion import FlaskApi, ProblemException, problem -from airflow import version - -if any(suffix in version.version for suffix in ['dev', 'a', 'b']): - doc_link = ( - "http://apache-airflow-docs.s3-website.eu-central-1.amazonaws.com/docs/apache-airflow/latest" - "/stable-rest-api-ref.html" - ) -else: - doc_link = f'https://airflow.apache.org/docs/{version.version}/stable-rest-api-ref.html' +from airflow.utils.docs import get_docs_url + +doc_link = get_docs_url("stable-rest-api-ref.html") EXCEPTIONS_LINK_MAP = { 400: f"{doc_link}#section/Errors/BadRequest", diff --git a/airflow/utils/docs.py b/airflow/utils/docs.py index 407061279fe3d8..2038ff0ec6e3cd 100644 --- a/airflow/utils/docs.py +++ b/airflow/utils/docs.py @@ -22,7 +22,7 @@ def get_docs_url(page: Optional[str] = None) -> str: """Prepare link to Airflow documentation.""" - if "dev" in version.version: + if any(suffix in version.version for suffix in ['dev', 'a', 'b']): result = ( "http://apache-airflow-docs.s3-website.eu-central-1.amazonaws.com/docs/apache-airflow/latest/" )