[Core SDK] Duplicate nested `_plugin_name` helper in plugins/__init__.py shadows module-level helper
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
- #5255 di @praisonai-triage-agent — chiusa senza merge
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Idoneità per principianti
- 50/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 9.3k
- Fork
- 1.5k
- Merge medio
- 1g 5h
- PR unite (30g)
- 520
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di MervinPraison/PraisonAI
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
MervinPraison/PraisonAI#6710 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
claude
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
MervinPraison/PraisonAI#6707 ·
I maintainer di solito rispondono entro 1 giorno
-
bug claude
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
MervinPraison/PraisonAI#6671 ·
I maintainer di solito rispondono entro 1 giorno
-
Compaction budget regression fixture remains below budget with accurate tokenizationForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
MervinPraison/PraisonAI#5418 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug claude documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
MervinPraison/PraisonAI#5341 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di MervinPraison/PraisonAI
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 2 giorni
-
[Bug]: LANGSMITH_SAMPLING_RATE ignores fractional values (isdigit check), traces 100% of requestsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
platform/backend tests
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Significant-Gravitas/AutoGPT#17100 ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 61/100
scverse/infercnvpy#238 ·
I maintainer di solito rispondono entro 1 giorno