Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python repl should support tab complete #20389

Closed
JettJones opened this issue Jan 10, 2024 · 5 comments
Closed

Python repl should support tab complete #20389

JettJones opened this issue Jan 10, 2024 · 5 comments
Labels
backend: Python Python backend-related issues enhancement

Comments

@JettJones
Copy link

Is your feature request related to a problem? Please describe.
Current versions of python 3.x support tab complete when run directly (https://docs.python.org/3/tutorial/interactive.html), it would be nice if this was also available in pants repl ....

Describe the solution you'd like
Matching behavior of python started directly / in interactive -i mode.

>>> x = []
>>> x.  # then tab generates:
x.append(   x.clear(    x.copy(     x.count(    x.extend(   x.index(    x.insert(   x.pop(      x.remove(   x.reverse(  x.sort(
>>> import sys
>>> sys.  # then tab generates:
sys.abiflags                              sys.getallocatedblocks(                   sys.path_hooks
sys.addaudithook(                         sys.getdefaultencoding(                   sys.path_importer_cache
sys.api_version                           sys.getdlopenflags(                       sys.platform
sys.argv                                  sys.getfilesystemencodeerrors(            sys.platlibdir
...

Describe alternatives you've considered
Running with --shell=ipython activates the autocomplete in ipython, but it's a slightly different interface, so one more thing to learn.

Additional context

@benjyw
Copy link
Contributor

benjyw commented Jan 10, 2024

Supporting this is a good idea. Would be great if you could do some further debugging here to see in what way the Pants repl is different from a standalone one, and why this might cause tab completion to be disabled.

@huonw huonw added the backend: Python Python backend-related issues label Jan 13, 2024
@jsirois
Copy link
Contributor

jsirois commented Jan 15, 2024

The underlying problem is in Pex and is being addressed here: pex-tool/pex#2321

Once Pex 2.1.158 is released with the fix, a Pants maintainer will need to upgrade the Pex version Pants uses / provide you with instructions on how to self-upgrade your existing Pants install using pants.toml config.

@jsirois
Copy link
Contributor

jsirois commented Jan 15, 2024

@benjyw
Copy link
Contributor

benjyw commented Jan 15, 2024

Thanks @jsirois !

@JettJones You can upgrade in your own repo by setting version and known_versions under [pex-cli] in your pants.toml, as described here.

If that works, we'd appreciate a PR that changes the default version of Pex that Pants uses, which is set here.

cburroughs added a commit to cburroughs/pants that referenced this issue Jan 16, 2024
Changelogs:
 * https://github.com/pantsbuild/pex/releases/tag/v2.1.157
 * https://github.com/pantsbuild/pex/releases/tag/v2.1.158
 * https://github.com/pantsbuild/pex/releases/tag/v2.1.159

```
Lockfile diff: 3rdparty/python/user_reqs.lock [python-default]

==                    Upgraded dependencies                     ==

  attrs                          23.1.0       -->   23.2.0
  pex                            2.1.156      -->   2.1.159
```

Enables repl tab completion for pantsbuild#20389
Fixes a bug with `pex3 lock update` of relevance for pantsbuild#15704
@JettJones
Copy link
Author

cburroughs patch works for me! Thanks for jumping on that.

benjyw pushed a commit that referenced this issue Jan 16, 2024
Changelogs:
 * https://github.com/pantsbuild/pex/releases/tag/v2.1.157
 * https://github.com/pantsbuild/pex/releases/tag/v2.1.158
 * https://github.com/pantsbuild/pex/releases/tag/v2.1.159

```
Lockfile diff: 3rdparty/python/user_reqs.lock [python-default]

==                    Upgraded dependencies                     ==

  attrs                          23.1.0       -->   23.2.0
  pex                            2.1.156      -->   2.1.159
```

Enables repl tab completion for #20389
Fixes a bug with `pex3 lock update` of relevance for #15704
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: Python Python backend-related issues enhancement
Projects
None yet
Development

No branches or pull requests

5 participants