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

Return pip install black[jupyter] hint with syntax to match platform #3254

Closed
wants to merge 1 commit into from

Conversation

Mitchellpkt
Copy link

Description

This change updates the message returned when Jupyter dependencies are not installed, so that it contains syntax corresponding to the platform.

Previously, attempting to apply black formatting to an ipynb notebook without black[jupyter] installed always returned the hint to run pip install black[jupyter]. This command does not work on Ubuntu with python3.

With this change, in the same scenario, the hint is pip install 'black[jupyter]' if "linux" is in the platform name, and the old hint pip install black[jupyter] otherwise.

The only function changed in the main codebase was black.handle_ipynb_magics.jupyter_dependencies_are_installed

I updated tests/test_no_ipynb.py to mock linux and non-linux versions of the existing tests.

Because this PR does not impact formatter rules or behavior, I did not update the CHANGELOG or documentation. However if I skipped any steps or missed anything please let me know, and I will take care of it :)

Checklist - did you ...

  • Add a CHANGELOG entry if necessary? -> Not sure if applicable
  • Add / update tests if necessary? -> Yes (tests/test_no_ipynb.py)
  • Add new / update outdated documentation? -> N/A

@zsol
Copy link
Collaborator

zsol commented Sep 3, 2022

Nit: this is not platform-dependent, but shell-dependent behavior.

Having said that: Couldn't we just change the prompt to be pip install 'black[jupyter]' instead for all platforms?

@Mitchellpkt
Copy link
Author

Ah yes, technically shell not platform, my bad.

pip install 'black[jupyter]' worked for me on Linux and Mac, but not Windows.

Windows test:

> pip install 'black[jupyter]'
ERROR: Invalid requirement: "'black[jupyter]'"

@github-actions
Copy link

github-actions bot commented Sep 3, 2022

diff-shades reports zero changes comparing this PR (e304e34) to main (92c93a2).


What is this? | Workflow run | diff-shades documentation

@Jackenmen
Copy link
Contributor

You can use double quotes which should work on all shells.

@Mitchellpkt
Copy link
Author

That seems much more straightforward! I can make a fresh PR later without the message switching 👍

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.

3 participants