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

Improve venv shell activation in fish shell #8804

Merged
merged 1 commit into from
Dec 20, 2023

Conversation

MrGreenTea
Copy link
Contributor

Instead of mimicking a user typing the command we use fish's builtin --init-command option. This is similar to how poetry already does it in nushell. This makes the experience a bit nicer because instead of it looking something like this:

poetry on  master is 📦 v1.8.0.dev0 via 🐍 v3.12.0 
❯ poetry shell
Spawning shell within ~/virtualenvs/poetry-4gAzItFB-py3.11
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish

poetry on  master is 📦 v1.8.0.dev0 via 🐍 v3.12.0 
❯ source ~/.cache/pypoetry/virtualenvs/poetry-4gAzItFB-py3.11/bin/activate.fish

poetry on  master is 📦 v1.8.0.dev0 via 🐍 v3.12.0 (poetry-py3.11) 
❯  _

it now looks like this (notice the missing source invokation)

❯ poetry shell
Spawning shell within ~/virtualenvs/poetry-4gAzItFB-py3.11
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish

poetry on  master is 📦 v1.8.0.dev0 via 🐍 v3.12.0 (poetry-py3.11) 
❯  _

The --init-command option has been released with fish version 2.7b1 in 2017 according to their changelog so in my opinion should not cause compatibility issues.

I didn't find any tests for the nu behavior but would add tests for this if wanted and with some small pointers about how you would like this to be tested.

  • Added tests for changed code.
  • Updated documentation for changed code.

Instead of mimicking a user typing the command we use
fish's builtin `--init-command` option.
@radoering
Copy link
Member

LGTM. Very good PR description. 👍

The --init-command option has been released with fish version 2.7b1 in 2017 according to their changelog so in my opinion should not cause compatibility issues.

Thanks for pointing this out. Should be fine.

I didn't find any tests for the nu behavior but would add tests for this if wanted and with some small pointers about how you would like this to be tested.

Nobody has come up with a sensible way to test this yet. Probably, simple tests would be quite pointless and useful tests are just too much effort.

@radoering radoering merged commit 5ddc81c into python-poetry:master Dec 20, 2023
20 checks passed
Copy link

github-actions bot commented Mar 3, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants