Make all `.to_file()` methods into context managers

Đang mở
#699 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

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá 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

Search the repository for all .to_file() methods and inspect their callers, starting with the usage in dwave-cloud-client linked from the issue and checking dwave-system compatibility. Determine which methods and call sites depend on the returned file remaining open; done means all affected methods use context managers and downstream integrations remain compatible.

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

Mô tả

enhancement question

I.e., change

class Model:
    def to_file(self, ...):
        file = tempfile.TemporaryFile(...)
        ...
        return file

to

class Model:
    @contextlib.contextmanager
    def to_file(self, ...):
        with tempfile.TemporaryFile(...) as file:
            ...
            yield file

I briefly tried to do this in https://github.com/dwavesystems/dwave-optimization/pull/697, but it has implications for the dwave-cloud-client and dwave-system so marking it for the future instead.

Ngôn ngữ chính
C++
Star
32
Fork
38
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
20

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 dwavesystems/dwave-optimization

Tất cả issue của dwavesystems/dwave-optimization

Issue tương tự

Thêm issue về C++

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.