Skip to main content

pre-commit-localupdate

A CLI tool to automatically update dependencies in pre-commit-config.yml files. It specifically targets additional_dependencies within local hooks to ensure your tooling stays up-to-date. It also adds version to unversioned packages and pins exact version of loosely defined ones to the absolute latest. You can also pin a specific package to an older version by adding a # freeze comment.

Installation

pip install pre-commit-localupdate

Usage

To check and update the additional_dependencies in your .pre-commit-config.yaml file, simply run:

pre-commit-localupdate

All options:

usage: pre-commit-localupdate [-h] [--debug] [--dry-run] [-c PRE-COMMIT-CONFIG] [--timeout TIMEOUT]
                              [--request-delay REQUEST_DELAY] [--indent-mapping INDENT_MAPPING]
                              [--indent-sequence INDENT_SEQUENCE] [--indent-offset INDENT_OFFSET]
                              [--line-width LINE_WIDTH] [--version]

Automatically update additional dependencies within local hooks in a pre-commit config file.

options:
  -h, --help                         show this help message and exit
  --debug                            enable debug logging (default: False)
  --dry-run                          dry run mode. Do not update the file and exit with a non-zero code if the
                                     configuration file require an update. (default: False)
  -c, --config PRE-COMMIT-CONFIG     pre-commit config file path (default: .pre-commit-config.yaml)
  --timeout TIMEOUT                  connection timeout in seconds (default: 10)
  --request-delay REQUEST_DELAY      minimum deplay between network requests in seconds (default: 1.0)
  --indent-mapping INDENT_MAPPING    YAML indentation for mappings (default: 2)
  --indent-sequence INDENT_SEQUENCE  YAML indentation for sequences (default: 4)
  --indent-offset INDENT_OFFSET      YAML indentation offset (default: 2)
  --line-width LINE_WIDTH            maximum line width (default: 80)
  --version                          show program's version number and exit

Example

Given a .pre-commit-config.yaml with the following content:

# File header is preserved. If there is no document start marker (---), it won't be added
---
repos:
  # External hooks won't be touched. Use 'pre-commit autoupdate' command to update them
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v2.3.0
    hooks:
      - id: end-of-file-fixer
      - id: trailing-whitespace

  - repo: local
    hooks:
      # All comment are preserved
      - id: black
        name: black
        description: "Length of strings is automatically adjusted based on the value of --line-width"
        entry: black
        language: python
        minimum_pre_commit_version: 2.9.2
        require_serial: true
        types_or: [python, pyi]
        additional_dependencies:
          # Loose version definitions are pinned to an exact version
          - "black>=25.1.0"
          # Updates can be prevented by adding a 'freeze' comment to them as:
          - "white==0.1.0"  # freeze

      - id: julia-format
        name: format julia code
        description: Unicodeテキストは保持されます。
        language: julia
        types: [julia]
        entry: tools/formatter.jl
        additional_dependencies:
          # Double/single quoting style is preserved and version is added to packages with no version definition
          - 'JuliaFormatter'

      - id: mdbook-lint
        name: mdbook-lint
        description: rust package to lint markdown
        entry: mdbook-lint lint --fix
        language: rust
        types: [markdown]
        # Updating packages defined in flow style is also supported
        additional_dependencies: ["cli:mdbook-lint"]

Running pre-commit-localupdate will update the file to (hypothetical latest versions):

# File header is preserved. If there is no document start marker (---), it won't be added
---
repos:
  # External hooks won't be touched. Use 'pre-commit autoupdate' command to update them
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v2.3.0
    hooks:
      - id: end-of-file-fixer
      - id: trailing-whitespace

  - repo: local
    hooks:
      # All comment are preserved
      - id: black
        name: black
        description: "Length of strings is automatically adjusted based on the value
          of --line-width"
        entry: black
        language: python
        minimum_pre_commit_version: 2.9.2
        require_serial: true
        types_or: [python, pyi]
        additional_dependencies:
          # Loose version definitions are pinned to an exact version
          - "black==26.1.0"
          # Updates can be prevented by adding a 'freeze' comment to them as:
          - "white==0.1.0"  # freeze

      - id: julia-format
        name: format julia code
        description: Unicodeテキストは保持されます。
        language: julia
        types: [julia]
        entry: tools/formatter.jl
        additional_dependencies:
          # Double/single quoting style is preserved and version is added to packages with no version definition
          - 'JuliaFormatter@2.3.0'

      - id: mdbook-lint
        name: mdbook-lint
        description: rust package to lint markdown
        entry: mdbook-lint lint --fix
        language: rust
        types: [markdown]
        # Updating packages defined in flow style is also supported
        additional_dependencies: ["cli:mdbook-lint:0.14.2"]

Supported Languages

Following local hook languages are currently supported:

  • Go (golang)
  • Julia
  • Node.js (node)
  • Python
  • Rust

Formatting

Significant effort has been made to ensure pre-commit-localupdate maintains the original style and preserves comments in pre-commit configuration files. However, since the current version of the underlying library does not perfectly preserve the original YAML file format after processing, pre-commit-localupdate automatically folds long string values (like descriptions) and enforces block indentation by default when updating files to enhance readability. Both behaviors can be adjusted using command-line parameters.

Requirements

  • packaging
  • requests
  • ruamel.yaml

License

  • Copyright 2026 M. Farzalipour Tabriz, Max Planck Institute for Physics (MPP)

All rights reserved. This software may be modified and distributed under the terms of the GNU Lesser General Public License (LGPL). See the LICENSE file for details.

Metadata

Release files for pre-commit-localupdate 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pre-commit-localupdate 0.6.0
File Size Uploaded
pre_commit_localupdate-0.6.0.tar.gz 12.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pre-commit-localupdate 0.6.0
File Interpreter ABI Platform
pre_commit_localupdate-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.4 kB

Release files / pre_commit_localupdate-0.6.0.tar.gz

Download URL pre_commit_localupdate-0.6.0.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
495344c98fc52ff71c8a95ec16e4f7dd9bef30a98eb586a83ebe2e5d2ef5b678
BLAKE2b-256 checksum
How to use checksums
81fb4c567200eab9ff0f9191344cc27257a57409aa6b22b72382a871ef48f7ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.27.0 CPython/3.12.3 Linux/6.8.0-138-generic

Release files / pre_commit_localupdate-0.6.0-py3-none-any.whl

Download URL pre_commit_localupdate-0.6.0-py3-none-any.whl
Size 19.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c32f33fe74689cad19ccf418270e0c12885a7fcff7b6f6771661c938a077b04c
BLAKE2b-256 checksum
How to use checksums
8090c14f8f83cbe76a10ca9b9f87f7d3b92964bfdb5a5a3df4c322907ca56aef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.27.0 CPython/3.12.3 Linux/6.8.0-138-generic

Release history Release notifications | RSS feed

0.7.0

2 release files

This release

0.6.0 This release

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page