python / python/importlib_metadata
Better identification of broken Distribution objects
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 142
- フォーク
- 97
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Currently, I'm getting an error on Python 3.8 and 3.9 in https://github.com/pypa/build/pull/820:
docker run --rm -it python:3.9 bash
pip install tox
git clone https://github.com/pypa/build
cd build
tox -e py39 -- -k test_metadata_path_no_prepare -v
...
File "/build/.tox/py39/lib/python3.9/site-packages/importlib_metadata/compat/py39.py", line 23, in normalized_name
return Prepared.normalize(getattr(dist, "name", None) or dist.metadata['Name'])
File "/build/.tox/py39/lib/python3.9/site-packages/importlib_metadata/__init__.py", line 889, in normalize
return re.sub(r"[-_.]+", "-", name).lower().replace('-', '_')
File "/usr/local/lib/python3.9/re.py", line 210, in sub
return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or bytes-like object
The problem is dist.__dict__={'_path': PosixPath('/build/tests/packages/test-no-prepare/test_no_prepare.egg-info')}. I think this is tripping up on tests/packages/test-no-prepare/test_no_prepare.egg-info/ and the local backend. But I don't know what updated to cause this to start happening.
Regardless of the solution, though, I think the handling here for a missing name should be better, there wasn't any useful info in the error message to tell me about the dist that was failing. I had to add print(f"{dist.__dict__=}") to see it. Or maybe the normalize name could return None, and let the failure happen elsewhere.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、issue に記載されている Python 3.9 の Docker および tox コマンドで失敗を再現し、次に importlib_metadata/compat/py39.py の normalized_name と importlib_metadata/init.py の normalize を読みます。_path だけを持つ Distribution がどのように名前の正規化に到達するかを追跡します。未指定または無効な名前から、失敗した Distribution を有用な形で特定でき、関連するテストが通れば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100