python / python/cpython

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

Open
#149,167 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib topic-repl type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the pyrepl autocomplete entry point for from x import <tab> and inspect the existing dir-like candidate filtering. Check the autocomplete tests, if present, and use the pathlib and collections.abc examples from the issue to verify that only names exposed by __all__ are listed; the linked PR gh-156146 indicates work is already underway.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.