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

FEAT: move imports to top in notebooks #392

Merged
merged 4 commits into from
Sep 23, 2024
Merged

FEAT: move imports to top in notebooks #392

merged 4 commits into from
Sep 23, 2024

Conversation

redeboer
Copy link
Member

@redeboer redeboer commented Sep 23, 2024

This is a temporary fix for ComPWA/compwa.github.io#270 and related issues/PRs. It uses isort to move all imports to the top of a notebook and then Ruff will do the rest of the sorting.

In practice, by adding the --imports-on-top flag to the `check-dev-files hook, the following pre-commit hook will be added:

  - repo: https://github.com/nbQA-dev/nbQA
    rev: 1.9.0
    hooks:
      - id: nbqa-isort
        args: [--float-to-top]
        # exclude: >
        #   (?x)^(
        #     my-notebook1\.ipynb|
        #     my-notebook2\.ipynb
        #   )$

Update: You'll have to add the following to your pyproject.toml in order to be compatible with Ruff:

[tool.isort]
profile = "black"

@redeboer redeboer added the ✨ Feature New feature added to the package label Sep 23, 2024
@redeboer redeboer self-assigned this Sep 23, 2024
@redeboer
Copy link
Member Author

Update: You'll have to add the following to your pyproject.toml in order to be compatible with Ruff:

[tool.isort]
profile = "black"

Copy link
Member

@shenvitor shenvitor left a comment

Choose a reason for hiding this comment

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

🍩

src/compwa_policy/check_dev_files/ruff.py Show resolved Hide resolved
@redeboer redeboer merged commit 4d13e2e into main Sep 23, 2024
24 checks passed
@redeboer redeboer deleted the nbqa-isort branch September 23, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature New feature added to the package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants