From edd2bad77b781379d7e659effa2cbc2971e37ff2 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Mon, 12 Jan 2026 10:51:13 -0800 Subject: [PATCH] Fix _docs_helpers.py import error in CI - Add try/except for relative vs absolute imports in _docs_helpers.py - Remove silent error handling in docs workflow (fail on error) The relative import fails when markdown-code-runner executes the code directly via sys.path.insert. The fallback to absolute import fixes this. --- .github/workflows/docs.yml | 3 ++- .../adaptive_lighting/_docs_helpers.py | 26 +++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c6817c8b..6e591f92 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -61,10 +61,11 @@ jobs: - name: Run markdown-code-runner on docs run: | + set -e for f in docs/*.md docs/**/*.md; do if [ -f "$f" ]; then echo "Processing $f..." - markdown-code-runner "$f" || echo "Warning: Failed to process $f" + markdown-code-runner "$f" fi done diff --git a/custom_components/adaptive_lighting/_docs_helpers.py b/custom_components/adaptive_lighting/_docs_helpers.py index 0c4ed45d..8611efa8 100644 --- a/custom_components/adaptive_lighting/_docs_helpers.py +++ b/custom_components/adaptive_lighting/_docs_helpers.py @@ -5,14 +5,24 @@ import pandas as pd import voluptuous as vol from homeassistant.helpers import selector -from .const import ( - DOCS, - DOCS_APPLY, - DOCS_MANUAL_CONTROL, - SET_MANUAL_CONTROL_SCHEMA, - VALIDATION_TUPLES, - apply_service_schema, -) +try: + from .const import ( + DOCS, + DOCS_APPLY, + DOCS_MANUAL_CONTROL, + SET_MANUAL_CONTROL_SCHEMA, + VALIDATION_TUPLES, + apply_service_schema, + ) +except ImportError: + from const import ( + DOCS, + DOCS_APPLY, + DOCS_MANUAL_CONTROL, + SET_MANUAL_CONTROL_SCHEMA, + VALIDATION_TUPLES, + apply_service_schema, + ) def _format_voluptuous_instance(instance: vol.All) -> str: