From c09c8588f0a3dd207071e41b2fffc0f7a144975b Mon Sep 17 00:00:00 2001 From: starmen1265 Date: Wed, 18 Mar 2026 00:03:02 +0800 Subject: [PATCH] fix(crawler): resolve circular import in zhihu_crawler Circular import chain: zhihu_crawler -> pipeline.config -> pipeline.platforms -> zhihu_crawler Fix: Lazy import get_settings() inside _get_cookie() method instead of module-level import. --- kb_workflow/crawler/zhihu_crawler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kb_workflow/crawler/zhihu_crawler.py b/kb_workflow/crawler/zhihu_crawler.py index b424da4..e343f5f 100644 --- a/kb_workflow/crawler/zhihu_crawler.py +++ b/kb_workflow/crawler/zhihu_crawler.py @@ -19,7 +19,8 @@ from playwright.sync_api import Route, Response, sync_playwright from tenacity import Retrying, stop_after_attempt, wait_exponential, RetryError from kb_workflow.metadata.zhihu_extractor import PlaywrightBrowser -from kb_workflow.pipeline.config import get_settings +# NOTE: get_settings is imported lazily in _get_cookie() to avoid circular import +# Circular: zhihu_crawler -> pipeline.config -> pipeline.platforms -> zhihu_crawler from .models import ( AnswerData, ArticleData, @@ -129,6 +130,9 @@ class ZhihuCrawler: Returns: Cookie string from settings """ + # Lazy import to avoid circular dependency: + # zhihu_crawler -> pipeline.config -> pipeline.platforms -> zhihu_crawler + from kb_workflow.pipeline.config import get_settings settings = get_settings() return settings.zhihu_cookie.get_secret_value()