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

Adding jupytext to pre commit to apply black to myst notebook code #607

Conversation

davidorme
Copy link
Collaborator

Description

This PR:

  • Adds jupytext --pipe black as a pre-commit step for the markdown files in docs/source, which auto-formats any Python in {code-cell} directives.
  • Updates markdown files to set the notebook language where needed and add Python3 to code cells.
  • Updates the metadata retained in markdown files (pyproject.toml: [tool.jupytext])

This is a little finicky and the implementation is being looked at:
mwouts/jupytext#1267

It is possible that we might be able to use ruff here but at present only the .ipynb format for notebooks is supported by ruff-format.

astral-sh/ruff#8800 (comment)

Fixes #154

Type of change

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist

  • Make sure you've run the pre-commit checks: $ pre-commit run -a
  • All tests pass: $ poetry run pytest

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works
  • Relevant documentation reviewed and updated

@codecov-commenter
Copy link

codecov-commenter commented Oct 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.18%. Comparing base (1b31149) to head (8729fab).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #607   +/-   ##
========================================
  Coverage    95.18%   95.18%           
========================================
  Files           74       74           
  Lines         4380     4380           
========================================
  Hits          4169     4169           
  Misses         211      211           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@jacobcook1995 jacobcook1995 left a comment

Choose a reason for hiding this comment

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

Skimmed the file changes at it looks sensible to me, happy for this to be merged once the docs build failures are fixed

@davidorme davidorme merged commit e690579 into develop Oct 16, 2024
13 checks passed
@davidorme davidorme deleted the 154-adding-jupytext-to-pre-commit-to-apply-black-to-myst-notebook-code branch October 16, 2024 16:55
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.

Adding jupytext to pre-commit to apply black to MyST notebook code.
3 participants