[Core SDK] Duplicate nested `_plugin_name` helper in plugins/__init__.py shadows module-level helper
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
- #5255 @praisonai-triage-agent による — マージされずにクローズ
評価
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 初心者へのやさしさ
- 50/100
調査の方向性
The shadowing copy is the nested _plugin_name inside enable() in praisonaiagents/plugins/init.py, around lines 194-198; the module-level helper at lines 94-104 is the one to keep, and disable() near line 269 already uses it. Read the closed, unmerged PR #5255 first to learn why it was rejected. Run tests/unit/plugins/test_plugins_enable.py and tests/unit/plugins/test_late_plugin_registration.py. Done means the nested definition is gone and those tests still pass.
索引モデルが issue の本文から書いたものです。
説明
Summary
praisonaiagents/plugins/__init__.py defines a nested _plugin_name() helper inside enable() that duplicates the module-level _plugin_name() already in scope. Removing the nested copy is a pure, behaviour-preserving de-duplication (and closes a small robustness divergence). This is not a feature change.
Current behaviour
Module-level helper — plugins/__init__.py:94-104:
def _plugin_name(plugin_info) -> str:
"""Read a plugin's name from a PluginInfo, or from a dict."""
if isinstance(plugin_info, dict):
return plugin_info.get("name", "")
return getattr(plugin_info, "name", "") or ""
Nested duplicate inside enable() — plugins/__init__.py:194-198:
def _plugin_name(plugin_info):
"""Read a plugin name from either PluginInfo or legacy dict data."""
if isinstance(plugin_info, dict):
return plugin_info.get("name", "")
return getattr(plugin_info, "name", "")
The nested definition shadows the module-level helper for the duration of enable(). disable() (plugins/__init__.py:269) already uses the module-level helper directly.
Why it matters
Maintenance. Two copies of the same helper have already drifted: the nested copy omits the module-level version's trailing or "" guard. A plugin object whose name attribute is None therefore returns None through enable()'s path but "" through disable()'s path — a subtle inconsistency for the exact edge case the module-level docstring was written to defend against. One helper removes the divergence.
Category
Duplicate
Capability preserved
enable()selective allow-list,enable()-all, anddisable()behaviour all unchanged.- Both
PluginInfodataclass and legacy-dict shapes still accepted (the module-level helper already handles both). - Registration allow-list gating, hook wiring, and per-plugin option delivery untouched.
Proposed approach
Remove the nested def _plugin_name (dead code — the identically-named module-level helper is already in scope and is strictly more robust). Remove dead code only; no API or behaviour change.
Resolution sketch
# Before — enable() carries a nested shadow of the module-level helper
def enable(...):
...
manager.set_registration_allow_list(target_plugins)
def _plugin_name(plugin_info):
if isinstance(plugin_info, dict):
return plugin_info.get("name", "")
return getattr(plugin_info, "name", "")
if target_plugins is not None:
...
name = _plugin_name(plugin_info)
# After — rely on the module-level helper (identical behaviour, adds the `or ""` guard)
def enable(...):
...
manager.set_registration_allow_list(target_plugins)
if target_plugins is not None:
...
name = _plugin_name(plugin_info) # module-level _plugin_name (lines 94-104)
Severity
Low
Validation
- Both definitions traced; the module-level helper is already referenced by
disable()(plugins/__init__.py:269) and remains in scope insideenable()once the shadow is removed. - Both are private (
_-prefixed) — no public API surface affected. tests/unit/plugins/test_plugins_enable.pyandtests/unit/plugins/test_late_plugin_registration.pyexercise the selective, all-plugins, and disable paths.- Confirmed not intentional robustness: the nested copy is the less robust of the two, so removing it cannot regress behaviour.
Keep unchanged
Plugin enable/disable semantics, selective allow-list gating, late-registration allow-list handling, hook-registry wiring, and per-plugin option (on_config) delivery.
- 主要言語
- Python
- スター
- 9.3k
- フォーク
- 1.5k
- 平均マージ
- 1日 5時間
- マージ済み PR(30日)
- 520
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
MervinPraison/PraisonAI のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
MervinPraison/PraisonAI#6710 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
claude
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
MervinPraison/PraisonAI#6707 ·
メンテナーはふだん 1 日以内に返信
-
bug claude
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
MervinPraison/PraisonAI#6671 ·
メンテナーはふだん 1 日以内に返信
-
Compaction budget regression fixture remains below budget with accurate tokenization再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
MervinPraison/PraisonAI#5418 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
bug claude documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
MervinPraison/PraisonAI#5341 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
MervinPraison/PraisonAI の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 2 日以内に返信
-
[Bug]: LANGSMITH_SAMPLING_RATE ignores fractional values (isdigit check), traces 100% of requestsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
platform/backend tests
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Significant-Gravitas/AutoGPT#17100 ·
メンテナーはふだん 1 日以内に返信
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 61/100
scverse/infercnvpy#238 ·
メンテナーはふだん 1 日以内に返信