This is an automated email from the ASF dual-hosted git repository. vatsrahul1001 pushed a commit to branch backport-a81cfb7-v3-4-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 09c6b6300b342292fe814afa25452249104bf10e Author: diederikvdv <[email protected]> AuthorDate: Tue Dec 1 01:44:09 2026 +0530 [v3-4-test] Fix failing __doc__ usage in case of PYTHONOPTIMIZE=2 (#77013) * Fix failing __doc__ usage in case of PYTHONOPTIMIZE=2 Handle case where __doc__ is None for description. PYTHONOPTIMIZE=2 drops the docstrings, causing an Attribute error when __doc__ is used * Add test for loading v2026_10_30 version changes without docstrings Compile the module with optimize=2, as python -OO / PYTHONOPTIMIZE=2 does, and execute it. Without the guard on inspect.cleandoc(__doc__) this raises AttributeError: 'NoneType' object has no attribute 'expandtabs'. --------- Co-authored-by: Shahar Epstein <[email protected]> (cherry picked from commit a81cfb7ac980d4b72a80765f076b51aa8fe124ad) Co-authored-by: diederikvdv <[email protected]> Co-Authored-By: Claude <[email protected]> --- .../execution_api/versions/v2026_10_30.py | 2 +- .../execution_api/versions/test_v2026_10_30.py | 32 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_10_30.py b/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_10_30.py index 2abb984dc73..6c69dbb2753 100644 --- a/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_10_30.py +++ b/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_10_30.py @@ -81,7 +81,7 @@ class IdentifyArchivedTaskStateUpdates(VersionChangeWithSideEffects): clients keep each endpoint's own response. """ - description = inspect.cleandoc(__doc__) + description = inspect.cleandoc(__doc__) if __doc__ is not None else None instructions_to_migrate_to_previous_version = () diff --git a/airflow-core/tests/unit/api_fastapi/execution_api/versions/test_v2026_10_30.py b/airflow-core/tests/unit/api_fastapi/execution_api/versions/test_v2026_10_30.py new file mode 100644 index 00000000000..f4583bb1be5 --- /dev/null +++ b/airflow-core/tests/unit/api_fastapi/execution_api/versions/test_v2026_10_30.py @@ -0,0 +1,32 @@ +# 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. +from __future__ import annotations + +import types +from pathlib import Path + +from airflow.api_fastapi.execution_api.versions import v2026_10_30 + + +def test_module_loads_without_docstrings(): + """The module must load under ``python -OO`` / ``PYTHONOPTIMIZE=2``, where ``__doc__`` is None.""" + source = Path(v2026_10_30.__file__).read_text() + namespace = vars(types.ModuleType(v2026_10_30.__name__)) + + exec(compile(source, v2026_10_30.__file__, "exec", optimize=2), namespace) + + assert namespace["IdentifyArchivedTaskStateUpdates"].description is None
