[BUG]: Duplicate `FigureWidget` import code in `graph_objects` and `graph_objs`

未關閉 適合新手
#5,849 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 2 天內回覆

@DawnofGenX 已經在處理了。

開始於 2026年10月27日。

  • #5850 來自 @DawnofGenX —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
76/100
Issue 類型
重構
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
python
領域
backend

研究方向

從 codegen/__init__.py 中的 optional_figure_widget_import 開始,接著閱讀 write_init_py 和 build_from_imports_py 如何產生兩個套件初始化檔。比較 plotly/graph_objs/__init__.py 和 plotly/graph_objects/__init__.py 中的 FigureWidget 區塊;完成標準是產生的程式碼保留現有的選擇性 ipywidgets 匯入和缺少相依套件時的備援機制,同時只輸出一次該區塊。檢查 issue #5238 中引用的備援測試。

由索引模型根據 Issue 內容生成。

描述

bug P3 size: 1
Description

The FigureWidget import code is duplicated in graph_objects and graph_objs.

Steps to reproduce
  • Open codegen/__init__.py and find optional_figure_widget_import.
  • Note that the codegen passes the string to write_init_py for graph_objs and to build_from_imports_py for graph_objects.
  • Open plotly/graph_objs/__init__.py and plotly/graph_objects/__init__.py.
  • Note the identical FigureWidget blocks at the end of each file.
Notes
  • The codegen writes the same optional FigureWidget import block into two generated files: plotly/graph_objs/__init__.py and plotly/graph_objects/__init__.py
  • graph_objects already re-exports every other class from graph_objs, including Figure. FigureWidget can follow the same path, because graph_objs handles the optional ipywidgets import and the missing_* fallback.
  • Any fix should not change behavior. This is just about removing duplicate code.
  • Related:
    • #3779 (closed, edited the generated file by hand)
    • #5238 (test for the missing FigureWidget fallback)
主要語言
Python
星號
18.9k
分支
2.9k
平均合併
1 天 22 小時
30 天內合併 PR
12

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

plotly/plotly.py 的其他 Issue

查看 plotly/plotly.py 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。