This is an automated email from the ASF dual-hosted git repository.
shahar1 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new a81cfb7ac98 Fix failing __doc__ usage in case of PYTHONOPTIMIZE=2
(#77013)
a81cfb7ac98 is described below
commit a81cfb7ac980d4b72a80765f076b51aa8fe124ad
Author: diederikvdv <[email protected]>
AuthorDate: Fri Nov 13 15:13:57 2026 +0100
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]>
---
.../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 7809e57bcf1..da5a090974b 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
@@ -82,7 +82,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