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

Mirrored pre-commit hook does not reformat notebooks #3835

Closed
brianhou opened this issue Aug 12, 2023 · 2 comments
Closed

Mirrored pre-commit hook does not reformat notebooks #3835

brianhou opened this issue Aug 12, 2023 · 2 comments
Labels
T: bug Something isn't working

Comments

@brianhou
Copy link

brianhou commented Aug 12, 2023

I've been using the black-jupyter pre-commit hook and was trying to update to the pre-commit mirror documented in #3828. However, the mirrored hook does not seem to reformat any files.

Describe the bug

To Reproduce

test.ipynb.txt (rename to remove the .txt extension)

With this entry in my .pre-commit-config.yaml and Jupyter notebook test.ipynb, running pre-commit run --hook-stage manual black-jupyter --files=test.ipynb does not reformat the notebook.

  - repo: https://github.com/psf/black-pre-commit-mirror
    rev: "23.7.0"
    hooks:
      - id: black-jupyter
        args:
          - --include='\.ipynb'
        stages: [manual]
        types_or: [jupyter]

With this entry in my .pre-commit-config.yaml and the same test.ipynb, running pre-commit run --hook-stage manual black-jupyter --files=test.ipynb does reformat the notebook.

  - repo: https://github.com/psf/black
    rev: "23.7.0"
    hooks:
      - id: black-jupyter
        args:
          - --include='\.ipynb'
        stages: [manual]
        types_or: [jupyter]

Expected behavior

The black-jupyter hook from the pre-commit mirror should reformat Jupyter notebooks.

Environment

  • Black's version: 23.7.0
  • OS and Python version: macOS, Python 3.10.5

Additional context

@brianhou brianhou added the T: bug Something isn't working label Aug 12, 2023
@brianhou brianhou changed the title Mirrored black-jupyter pre-commit hook doesn't work Mirrored black-jupyter pre-commit hook does not reformat notebooks Aug 12, 2023
@brianhou brianhou changed the title Mirrored black-jupyter pre-commit hook does not reformat notebooks Mirrored pre-commit hook does not reformat notebooks Aug 12, 2023
@hauntsaninja
Copy link
Collaborator

Hmm the mirror probably needs to specify a jupyter extra that installs black[jupyter] (since .[jupyter] no longer refers to the same thing between the two repos)

@hauntsaninja
Copy link
Collaborator

Okay, I've fixed this. You'll need to run pre-commit clean or set rev to a sha like 4f9accde9875c9559acf6d12a3eefeee0fd722f1 in order to pick this up. Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants