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

Đang mở Phù hợp với người mới
#5,849 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@DawnofGenX đang làm issue này rồi.

Từ ngày 27/10/2026.

  • #5850 của @DawnofGenX — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
76/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu tại codegen/__init__.py, ở optional_figure_widget_import, rồi đọc cách write_init_py và build_from_imports_py tạo hai tệp khởi tạo gói. So sánh các khối FigureWidget trong plotly/graph_objs/__init__.py và plotly/graph_objects/__init__.py; công việc hoàn tất khi mã được tạo vẫn giữ phần nhập ipywidgets tùy chọn hiện có và phương án dự phòng khi thiếu dependency, đồng thời chỉ xuất khối này một lần. Kiểm tra bài kiểm thử phương án dự phòng được tham chiếu trong issue #5238.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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)
Ngôn ngữ chính
Python
Star
18.9k
Fork
2.9k
Merge trung bình
1 ngày 22 giờ
Pull request đã merge (30 ngày)
12

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của plotly/plotly.py

Tất cả issue của plotly/plotly.py

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.