[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 摘要。