Skip to content

Repository files navigation

lychee-pre-commit

A pre-commit hook for lychee, the fast, async, stream-based link checker written in Rust.

It installs lychee from the prebuilt lychee-bin wheels that the lychee project publishes to PyPI, so it works on Windows, macOS, and Linux with no Rust toolchain, cargo, or bash required.

Why this exists

lychee already ships official pre-commit hooks. The recommended auto-installing lychee hook is a bash script, so it fails on Windows, which has no bash by default (lycheeverse/lychee#2238).

The natural fix — a language: python hook installed from PyPI — cannot live in the lychee repository itself. pre-commit installs a language: python hook by running pip install . against the hook repo's root, and lychee's root pyproject.toml is a maturin build config, so that would try to compile lychee from source instead of fetching a prebuilt binary.

A small standalone repository sidesteps that: its only dependency is the lychee-bin wheel, so pre-commit installs the right prebuilt binary on every platform. This is the same approach Ruff takes with ruff-pre-commit, and which rumdl-pre-commit and ryl-pre-commit copied.

Note

This is an unofficial mirror maintained by @owenlamont. It only repackages the prebuilt lychee-bin wheels that the lychee project already publishes to PyPI; all credit for lychee belongs to its authors and maintainers. If lychee publishes an equivalent hook under the lycheeverse umbrella, prefer that.

Usage

Add the hook to your .pre-commit-config.yaml:

repos:
  - repo: https://github.com/owenlamont/lychee-pre-commit
    # Match the lychee release you want to pin.
    rev: v0.24.2
    hooks:
      - id: lychee

The hook runs lychee --no-progress over the text files in your commit. Pass additional CLI options through the args key, for example to exclude some schemes:

  - repo: https://github.com/owenlamont/lychee-pre-commit
    rev: v0.24.2
    hooks:
      - id: lychee
        args: [--no-progress, --exclude, "file://", --exclude, "mailto:"]

On non-Windows systems you can also use lychee's official hooks directly, including the lychee-system and lychee-docker variants.

How releases track lychee

A scheduled workflow polls PyPI for new lychee-bin releases and, when one appears, bumps the pinned version here and publishes a matching vX.Y.Z tag and GitHub release. Pin rev: to the lychee version you want.

License

MIT (see LICENSE). lychee itself is dual-licensed under Apache-2.0 or MIT.

About

Pre-commit hook for lychee, the fast link checker (installs the prebuilt lychee-bin PyPI wheels; works on Windows, macOS, and Linux).

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages