Skip to content

pre-commit updates with Ruff#2184

Merged
nriley merged 7 commits intotalonhub:mainfrom
nriley:pre-commit
Apr 25, 2026
Merged

pre-commit updates with Ruff#2184
nriley merged 7 commits intotalonhub:mainfrom
nriley:pre-commit

Conversation

@nriley
Copy link
Copy Markdown
Collaborator

@nriley nriley commented Apr 25, 2026

From the Community Backlog session — we are using a combination of pre-commit hooks which are no longer supported, no longer relevant, slow or have newer/better alternatives.

  - repo: https://github.com/pre-commit/mirrors-prettier
    rev: "v4.0.0-alpha.8"
    hooks:
      - id: prettier

this is in use for JavaScript, CSS, JSON, etc. — probably for JSON/YAML/Markdown. The repository above is archived and we should find an alternative. @AndreasArvidsson recommends we give oxc a look.

  - repo: https://github.com/ikamensh/flynt
    rev: "1.0.6"
    hooks:
      - id: flynt

I think we can remove this entirely as it's there to support migration to Python 3.6 string formatting.

  - repo: https://github.com/pycqa/isort
    rev: 8.0.1
    hooks:
      - id: isort
  - repo: https://github.com/psf/black-pre-commit-mirror
    rev: 26.3.1
    hooks:
      - id: black

these two can be replaced by Ruff, as in this PR.

Copy link
Copy Markdown
Collaborator

@AndreasArvidsson AndreasArvidsson left a comment

Choose a reason for hiding this comment

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

Looks good. Just had one small change I think we need to make.

Comment thread apps/mintty/mintty_win.py Outdated
Comment thread .pre-commit-config.yaml Outdated
nriley and others added 2 commits April 25, 2026 13:31
Co-authored-by: Andreas Arvidsson <andreas.arvidsson87@gmail.com>
Co-authored-by: Andreas Arvidsson <andreas.arvidsson87@gmail.com>
@nriley
Copy link
Copy Markdown
Collaborator Author

nriley commented Apr 25, 2026

CI is happy now. I ran into an issue with pre-commit.ci versions which I filed and worked around.

Comment thread .pre-commit-config.yaml Outdated
Comment thread .pre-commit-config.yaml Outdated
Comment thread .pre-commit-config.yaml Outdated
@nriley nriley merged commit 4eadd8f into talonhub:main Apr 25, 2026
2 checks passed
@nriley nriley deleted the pre-commit branch April 25, 2026 18:16
Comment thread .pre-commit-config.yaml
Comment on lines +36 to +37
# Want to use pyproject instead of toml, but pre-commit.ci doesn't yet support it.
types_or: [python, toml]
Copy link
Copy Markdown
Collaborator

@auscompgeek auscompgeek Apr 26, 2026

Choose a reason for hiding this comment

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

FWIW pre-commit.ci always runs pre-commit run -a so the hook would always run in CI anyway.

Copy link
Copy Markdown
Collaborator Author

@nriley nriley Apr 26, 2026

Choose a reason for hiding this comment

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

Sorry, not sure how that addresses my concern. The issue is if I use types_or: [python, pyproject] to limit the types of files that Ruff evaluates, pre-commit.ci barfs because it does not use a new enough version of identify — see pre-commit-ci/issues#265. I'll try to get a PR submitted today to get this fixed as requested (update: done and merged; I'll try this again next week as not sure how long it takes for the production service to be updated).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If you don't specify this at all ruff would still check (by necessity) the pyproject.toml, wouldn't it?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The Ruff pre commit hook specifies by default types_or: [python, pyi, jupyter] so I don't think so.
https://github.com/astral-sh/ruff-pre-commit/blob/6fec9b7edb08fd9989088709d864a7826dc74e80/.pre-commit-hooks.yaml#L6

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The types_or tells pre-commit what files to collect and pass to the hook. But ruff needs to read pyproject.toml since that's how you configure ruff in the first place. So it should report issues with parsing its own config regardless?

Sure, adding it here would mean that a local pre-commit run (or prek run) will rerun ruff if you change the pyproject.toml (without touching any Python files). But that will never be an issue for CI.

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