python / python/cpython

pyrepl autocomplete from x import <tab> to only display public members

未關閉
#149,167 2 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

stdlib topic-repl type-feature
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

Feature or enhancement

Proposal:

When using autocomplete in the REPL, from x import <tab> will show all non-underscore prefixed members. This is a dir-like behavior that is useful to inspect and understand what can be imported.

However, this mechanism isn't filtering on __all__ of the module and can yield a long list of non-useful candidates to autocomplete. Two examples shown below, pathlib and collections.abc.

The feature request is that when a user enters from x import <tab> only the candidates defined in __all__ are listed.

Image Image
Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs
  • gh-156146

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

from x import <tab> 的 pyrepl 自動完成入口開始,檢查現有的類 dir 候選項篩選邏輯。檢查自動完成測試(如果有),並使用 issue 中的 pathlib 和 collections.abc 範例來驗證只有由 __all__ 公開的名稱才會被列出;連結的 PR gh-156146 表明相關工作已經在進行中。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
cli
Issue 類型
功能
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。