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

Incorrect dependencies for jupyter #1

Closed
henryiii opened this issue Aug 15, 2023 · 2 comments
Closed

Incorrect dependencies for jupyter #1

henryiii opened this issue Aug 15, 2023 · 2 comments

Comments

@henryiii
Copy link

pre-commit does not allow you to reference "." inside additional_dependencies; it literally places a dumpy setup.py and removes pyproject.toml during this phase. So this doesn't install any dependencies required.

This currently produces the following output:

Skipping .ipynb files as Jupyter dependencies are not installed.
You can fix this by running ``pip install "black[jupyter]"``

I think the easiest (only?) fix would be to manually include the Jupyter dependencies in this hook.

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Aug 15, 2023

Hmm, as far as I can tell, it does and the pre-commit hook now works as expected:

λ black --diff test.ipynb
--- test.ipynb	2023-08-15 19:45:52.425327+00:00:cell_0
+++ test.ipynb	2023-08-15 19:46:12.394367+00:00:cell_0
@@ -1 +1 @@
-test     =    'test'  
+test = "test"
would reformat test.ipynb

All done! ✨ 🍰 ✨
1 file would be reformatted.

λ pre-commit clean
Cleaned /Users/shantanu/.cache/pre-commit.

λ find ~/.cache/pre-commit/ | grep tokenize_rt-5.2.0.dist-info/RECORD
find: /Users/shantanu/.cache/pre-commit/: No such file or directory

λ pre-commit run -a
[INFO] Initializing environment for https://github.com/psf/black-pre-commit-mirror.
[INFO] Initializing environment for https://github.com/psf/black-pre-commit-mirror:.[jupyter].
[INFO] Installing environment for https://github.com/psf/black-pre-commit-mirror.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
black-jupyter............................................................Failed
- hook id: black-jupyter
- files were modified by this hook

reformatted test.ipynb

All done! ✨ 🍰 ✨
1 file reformatted.

λ find ~/.cache/pre-commit/ | grep tokenize_rt-5.2.0.dist-info/RECORD
/Users/shantanu/.cache/pre-commit//repo8e4t1kiq/py_env-python3.9/lib/python3.9/site-packages/tokenize_rt-5.2.0.dist-info/RECORD

Where do you see the removal of pyproject.toml?

Note that I previously had a bug psf/black#3835 where I did not specify optional-dependencies at all. I don't use the jupyter integration much and had just copied the pre-commit-config.yaml over, without realising that . would now refer to the dummy project instead of black. I fixed this in 2b84e5a

Unfortunately, the only way for me to fix this for past versions was to commit the minor sin of updating the tags in-place. I felt this was okay since a) I didn't see another way, b) technically the mirror is still in the "unreleased" section of the changelog, c) while philosophically sketchy I didn't see a downside from a consequentialist perspective, d) at the end of the day, tags are mutable.

So possible you installed more than three days ago and had the buggy version. In which case, can you check if using pre-commit clean fixes for you?

@henryiii
Copy link
Author

Yes, that seems to be it. Refreshing my cached environments did make the problem go away, thank you!

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

No branches or pull requests

2 participants