This is an automated email from the ASF dual-hosted git repository.
potiuk 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 be4d8943d3 Dedent help string in breeze configuration (#43555)
be4d8943d3 is described below
commit be4d8943d3dfe4239cd8becf2ad506b241db3a37
Author: Jarek Potiuk <[email protected]>
AuthorDate: Thu Oct 31 19:17:30 2024 +0100
Dedent help string in breeze configuration (#43555)
In Python 3.13 compiler, docstrings are automatically dedented. And
while Python 3.13 is not yet officially supported by Airflow for
some strange (and unknown) reasons, when you install breeze with
uv tools that have Python 3.13 installed, it might get into
a state that the docstrings are dedented in Breeze's bytecode and
it causes hash calculation for configuration options that have
docstring-generated help differs on different installations.
In order to make it consistent - we are now always dedenting the
help strings before hash calculation.
See https://github.com/python/cpython/issues/81283
---
dev/breeze/doc/images/output_build-docs.txt | 2 +-
dev/breeze/doc/images/output_prod-image.txt | 2 +-
dev/breeze/doc/images/output_prod-image_build.txt | 2 +-
dev/breeze/doc/images/output_setup.txt | 2 +-
.../doc/images/output_setup_autocomplete.txt | 2 +-
dev/breeze/doc/images/output_setup_config.txt | 2 +-
dev/breeze/doc/images/output_start-airflow.txt | 2 +-
.../src/airflow_breeze/commands/setup_commands.py | 26 +++++++++++++++++++++-
8 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/dev/breeze/doc/images/output_build-docs.txt
b/dev/breeze/doc/images/output_build-docs.txt
index 4bebe1e163..644e9bf767 100644
--- a/dev/breeze/doc/images/output_build-docs.txt
+++ b/dev/breeze/doc/images/output_build-docs.txt
@@ -1 +1 @@
-03dd58933b63fc368157f716b1852e1b
+b349182dab04b6ff58acd122a403a5a4
diff --git a/dev/breeze/doc/images/output_prod-image.txt
b/dev/breeze/doc/images/output_prod-image.txt
index 4e4ac97bd6..c767ee09d4 100644
--- a/dev/breeze/doc/images/output_prod-image.txt
+++ b/dev/breeze/doc/images/output_prod-image.txt
@@ -1 +1 @@
-55030fe0d7718eb668fa1a37128647b0
+d91bcc76b14f186e749efe2c6aaa8682
diff --git a/dev/breeze/doc/images/output_prod-image_build.txt
b/dev/breeze/doc/images/output_prod-image_build.txt
index 7799e6f009..9c6c509a66 100644
--- a/dev/breeze/doc/images/output_prod-image_build.txt
+++ b/dev/breeze/doc/images/output_prod-image_build.txt
@@ -1 +1 @@
-d0214e8e95fcb56c91e0e416690eb24f
+fe048412f9fc1527a30eaaf0a986fa16
diff --git a/dev/breeze/doc/images/output_setup.txt
b/dev/breeze/doc/images/output_setup.txt
index b8f9048b91..274751197d 100644
--- a/dev/breeze/doc/images/output_setup.txt
+++ b/dev/breeze/doc/images/output_setup.txt
@@ -1 +1 @@
-d4a4f1b405f912fa234ff4116068290a
+08c78d9dddd037a2ade6b751c5a22ff9
diff --git a/dev/breeze/doc/images/output_setup_autocomplete.txt
b/dev/breeze/doc/images/output_setup_autocomplete.txt
index 185feef026..144c2613cd 100644
--- a/dev/breeze/doc/images/output_setup_autocomplete.txt
+++ b/dev/breeze/doc/images/output_setup_autocomplete.txt
@@ -1 +1 @@
-fffcd49e102e09ccd69b3841a9e3ea8e
+ec3b4541a478afe5cb86a6f1c48f50f5
diff --git a/dev/breeze/doc/images/output_setup_config.txt
b/dev/breeze/doc/images/output_setup_config.txt
index 6bc958bebb..09ae63f096 100644
--- a/dev/breeze/doc/images/output_setup_config.txt
+++ b/dev/breeze/doc/images/output_setup_config.txt
@@ -1 +1 @@
-ee2e731f011b1d93dcbfbcaebf6482a6
+235af93483ea83592052476479757683
diff --git a/dev/breeze/doc/images/output_start-airflow.txt
b/dev/breeze/doc/images/output_start-airflow.txt
index 4618c5d3b4..bde82e04f0 100644
--- a/dev/breeze/doc/images/output_start-airflow.txt
+++ b/dev/breeze/doc/images/output_start-airflow.txt
@@ -1 +1 @@
-02160e5d799a77830ac522c628e90aed
+d5d7f9a299c80596dbba0a50f2f32f1c
diff --git a/dev/breeze/src/airflow_breeze/commands/setup_commands.py
b/dev/breeze/src/airflow_breeze/commands/setup_commands.py
index ad5ade3881..6701b03b48 100644
--- a/dev/breeze/src/airflow_breeze/commands/setup_commands.py
+++ b/dev/breeze/src/airflow_breeze/commands/setup_commands.py
@@ -22,6 +22,7 @@ import os
import shutil
import subprocess
import sys
+import textwrap
from copy import copy
from pathlib import Path
from typing import Any
@@ -255,8 +256,31 @@ def change_config(
get_console().print()
-def dict_hash(dictionary: dict[str, Any]) -> str:
+def dedent_help(dictionary: dict[str, Any]) -> None:
+ """
+ Dedent help stored in the dictionary.
+
+ Python 3.13 automatically dedents docstrings retrieved from functions.
+ See https://github.com/python/cpython/issues/81283
+
+ However, click uses docstrings in the absence of help strings, and we are
using click
+ command definition dictionary hash to detect changes in the command
definitions, so if the
+ help strings are not dedented, the hash will change.
+
+ That's why we must de-dent all the help strings in the command definition
dictionary
+ before we hash it.
+ """
+ for key, value in dictionary.items():
+ if isinstance(value, dict):
+ dedent_help(value)
+ elif key == "help" and isinstance(value, str):
+ dictionary[key] = textwrap.dedent(value)
+
+
+def dict_hash(dictionary: dict[str, Any], dedent_help_strings: bool = True) ->
str:
"""MD5 hash of a dictionary. Sorted and dumped via json to account for
random sequence)"""
+ if dedent_help_strings:
+ dedent_help(dictionary)
# noinspection InsecureHash
dhash = hashlib.md5()
try: