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

オープン
#699 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
C++
スター
32
フォーク
38
平均マージ
1日 23時間
マージ済み PR(30日)
20

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dwavesystems/dwave-optimization のほかの issue

dwavesystems/dwave-optimization の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。