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

?? prompt should be wrapped in paranthesis ?? #2224

Merged
merged 24 commits into from
Oct 31, 2021
Merged

?? prompt should be wrapped in paranthesis ?? #2224

merged 24 commits into from
Oct 31, 2021

Conversation

tusharsadhwani
Copy link
Contributor

@tusharsadhwani tusharsadhwani commented Oct 24, 2021

Thanks for contributing, make sure you address all the checklists (for details on how see

development documentation)!

  • ran the linter to address style issues (tox -e fix_lint)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
  • added news fragment in docs/changelog folder
  • updated/extended the documentation

This adds brackets and a space around the prompt text, in the case of --prompt=.

Previous behaviour:

$ pwd
/code/myproject

$ virtualenv venv --prompt .
[...]
$ . venv/bin/activate
myproject$ 

New behaviour:

$ virtualenv venv --prompt .
[...]
$ . venv/bin/activate
(myproject) $ 

This is a super trivial change, should I make a news fragment for this?

Copy link
Contributor

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this is not a fix. it's a feature as it changes current behaviour.

src/virtualenv/activation/activator.py Outdated Show resolved Hide resolved
@gaborbernat gaborbernat changed the title Fix formatting of --promt=. ?? prompt should be wrapped in paranthesis ?? Oct 24, 2021
Copy link
Contributor

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic looks alright, can you amend the existing tests to check for it?

@tusharsadhwani
Copy link
Contributor Author

I can't find where/how I'd add a test for it :')
I can't see anywhere the actual PS1 is being tested

@gaborbernat
Copy link
Contributor

I can't find where/how I'd add a test for it :')
I can't see anywhere the actual PS1 is being tested

Probably here https://github.com/pypa/virtualenv/blob/main/tests/unit/activation/conftest.py#L125 you'd need to extend it 🤔 and then assert here https://github.com/pypa/virtualenv/blob/main/tests/unit/activation/conftest.py#L139

@tusharsadhwani
Copy link
Contributor Author

Okay, adding platform-specific prompt checks will take a while.
PS1 only exists on bash it seems.
For powershell I'd have to run the prompt function somehow? Not sure about the rest at all

@gaborbernat
Copy link
Contributor

Thank you! No worries. We are not in a rush 😊

@tusharsadhwani
Copy link
Contributor Author

tusharsadhwani commented Oct 30, 2021

Sorry for testing everything on CI, but it all works now.

Weirdly though, the test_fish[no_prompt] test is failing on CI while it works fine locally. For some reason the order of %s in the printf command gets swapped on CI for the fish activation script. (Edit: Removing the set_color calls does work around that.)

As for powershell, the non-ASCII characters are messing up.
Expected: '(e-$ è-j) PS '
Actual prompt: '(e-$ è-j) PS '

Expected: 'èрт🚒♞中片-j\r\n PS '
Actual: '(e-$ èрт🚒♞ä¸\xad片-j) PS '
To fix this, I had to make it so that windows only gets an ascii venv name.

@gaborbernat
Copy link
Contributor

Sorry for testing everything on CI, but it all works now.

Weirdly though, the test_fish[no_prompt] test is failing on CI while it works fine locally.

The CI is the true judge of everything works fine 😃 so you'll need to fix the CI for this to be ready to review 🙏

@tusharsadhwani
Copy link
Contributor Author

@gaborbernat All done, PTAL :)

Copy link
Contributor

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good the only thing remaining is a changelog entry, as a feature, announcing the change in behaviour.

@tusharsadhwani
Copy link
Contributor Author

It's crazy that some of these checks take 60-90 mins to run. There must be a better way 🤔

But anyway, doc entry has also been added, hopefully I did it right.

@gaborbernat
Copy link
Contributor

It's crazy that some of these checks take 60-90 mins to run. There must be a better way

Not that I'm aware so if you have suggestions don't hold back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants