Skip to content

Conversation

@TimMonko
Copy link
Contributor

@TimMonko TimMonko commented Nov 28, 2025

Description

Driven mostly by curiosity and the desire for simplification, this slims down formatting/linting config for the template:
It drops black as a formatter and just uses ruff for everything. To take care of the template, ruff.toml has been added. Both pre-commits have been updated to use ruff as well.

  1. target-version is handled by a last-supported/latest-supported approach https://docs.astral.sh/ruff/settings/#target-version
  2. exclude is not needed because everything except vendored is a default for this setting https://docs.astral.sh/ruff/settings/#exclude , we do not expect plugin developers to use vendoring very often, so we can drop this config
  3. E501 is handled magically by ruff, where it may be too long but opt not to drop for trailing comma sake. I think it is fuzzy out to 88 characters by testing, but does respect our 79 https://docs.astral.sh/ruff/settings/#line-length

Other changed files have just been hit with ruff format/ruff check or were manually update to pass pre-commit checks (in cases where .py.jinja contain jinja syntax, ruff is unable to work). So now the root and template python files are formatted as expected

(I also added cancel concurrency because tests were taking even longer to run...)

@TimMonko
Copy link
Contributor Author

@guiwitz another one for you to review :)

@TimMonko TimMonko requested a review from Czaki November 28, 2025 04:57
Copy link
Contributor

@brisvag brisvag left a comment

Choose a reason for hiding this comment

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

Same as we did in napari/napari, I suggest to use single quote and not double quote as default. It's one less keystroke (so more commonly used and leads to smaller changes from the formatter), and less visually noisy.

@TimMonko
Copy link
Contributor Author

Same as we did in napari/napari, I suggest to use single quote and not double quote as default. It's one less keystroke (so more commonly used and leads to smaller changes from the formatter), and less visually noisy.

Thanks for greatly encouraging this! I meant to do such, but when I was doing ruff format it would ... always use double quotes? Well, I finally realized its because it wasn't reading pyproject.toml.jinja and instead just doing ruff defaults.

So I opted to add ruff.toml to the root and now everything lints well, with the inclusion/exclusion patterns. Just need to manually update with interior jinja syntax.

I've updated the description with this new info.

@TimMonko TimMonko changed the title Simplify ruff config, drop black formatting Simplify ruff config, drop black, and update pre-commit Dec 3, 2025
Copy link
Contributor

@Czaki Czaki left a comment

Choose a reason for hiding this comment

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

Please also update template/pyproject.toml.jinja then you will need to copy this changes https://github.com/napari/napari-plugin-template/pull/124/files#diff-35e54f0879a33f83222b35a59507b6a8b3409371455aa67530a06b75aadcc79d

We need to find way to force sync between template pre-comit and repository pre-commit

@TimMonko TimMonko requested a review from Czaki December 3, 2025 21:20
Copy link
Contributor

@Czaki Czaki left a comment

Choose a reason for hiding this comment

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

Ok. I see that I do not update _tasks.py so I need to make other changes in files to pass pre-commit checks.

@Czaki Czaki merged commit fd2b776 into napari:main Dec 4, 2025
12 checks passed
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