Skip to content

Commit

Permalink
Restore rendering of provider configuration with version_addded (#34011)
Browse files Browse the repository at this point in the history
The `version_added` for packages should use package version, not
Airflow version.

Fixes: #34005
  • Loading branch information
potiuk committed Sep 1, 2023
1 parent 04e9b0b commit 5595075
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from typing import Any

import yaml
from packaging.version import parse as parse_version
from packaging.version import Version, parse as parse_version

import airflow
from airflow.configuration import AirflowConfigParser, retrieve_configuration_description
Expand Down Expand Up @@ -410,6 +410,7 @@ def _get_rst_filepath_from_path(filepath: pathlib.Path):

def get_configs_and_deprecations(
package_name: str,
package_version: Version,
) -> tuple[dict[str, dict[str, tuple[str, str, str]]], dict[str, dict[str, tuple[str, str, str]]]]:
deprecated_options: dict[str, dict[str, tuple[str, str, str]]] = defaultdict(dict)
for (section, key), (
Expand Down Expand Up @@ -438,7 +439,7 @@ def get_configs_and_deprecations(
if option[key] and "{{" in option[key]:
option[key] = option[key].replace("{{", "{").replace("}}", "}")
version_added = option["version_added"]
if version_added is not None and parse_version(version_added) > airflow_version:
if version_added is not None and parse_version(version_added) > package_version:
del conf_section["options"][option_name]

# Sort options, config and deprecated options for JINJA variables to display
Expand All @@ -452,7 +453,7 @@ def get_configs_and_deprecations(

# Jinja context
if PACKAGE_NAME == "apache-airflow":
configs, deprecated_options = get_configs_and_deprecations(PACKAGE_NAME)
configs, deprecated_options = get_configs_and_deprecations(PACKAGE_NAME, airflow_version)
jinja_contexts = {
"config_ctx": {"configs": configs, "deprecated_options": deprecated_options},
"quick_start_ctx": {
Expand All @@ -465,7 +466,7 @@ def get_configs_and_deprecations(
},
}
elif PACKAGE_NAME.startswith("apache-airflow-providers-"):
configs, deprecated_options = get_configs_and_deprecations(PACKAGE_NAME)
configs, deprecated_options = get_configs_and_deprecations(PACKAGE_NAME, parse_version(PACKAGE_VERSION))
jinja_contexts = {
"config_ctx": {
"configs": configs,
Expand Down

0 comments on commit 5595075

Please sign in to comment.