python / python/cpython

importlib.resources.simple ResourceContainer/ResourceHandle cannot be instantiated

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

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

stdlib topic-importlib type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Bug report

Bug description:

Issue

ResourceContainer and ResourceHandle cannot be instantiated because Traversable now declares name as an abstract property. Additionally, ResourceContainer.iterdir() accesses self.reader.resources without calling it, and ResourceHandle.joinpath has a signature mismatch with the base class.

Reproducer

from importlib.resources.simple import ResourceContainer, SimpleReader
import io

class R(SimpleReader):
    @property
    def package(self): return 'x'
    def children(self): return []
    def resources(self): return []
    def open_binary(self, r): return io.BytesIO(b'')

ResourceContainer(R()) # TypeError: Can't instantiate abstract class ResourceContainer
CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs
  • gh-145263

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

調査の方向性

importlib.resources.simple から始め、ResourceContainer、ResourceHandle、SimpleReader、およびそれらの Traversable との関係を調査します。ResourceContainer(R()) の失敗を再現し、その後、abstract-property、resources へのアクセス、joinpath の問題が修正され、関連するテストでカバーされていることを確認します。

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

評価

技術スタック
python
領域
backend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
20/100

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

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