A CLI tool to automatically update additional dependencies within local Python, Julia, Rust, and Node.js hooks in pre-commit config files.
Project description
pre-commit-localupdate
A CLI tool to automatically update dependencies in pre-commit-config.yml files. It specifically targets additional_dependencies within local Python, Julia, Rust, and Node.js hooks to ensure your tooling stays up-to-date. It also adds version to unversioned packages and pins exact version of loosely defined ones. 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
By default, the tool looks for .pre-commit-config.yaml in the current directory. To specify a custom file path, use the -c or --config argument:
pre-commit-localupdate --config path/to/.pre-commit-config.yaml
To check the dependencies without updating, use the --dry-run flag. The command will exit with a non-zero status code if any package needs updating:
pre-commit-localupdate --dry-run
To get debug output use --debug flag:
pre-commit-localupdate --debug
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: "Long strings are automatically folded into multilines by ruamel-yaml library!"
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: Run `JuliaFormatter.jl` against Julia source files
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: "Long strings are automatically folded into multilines by ruamel-yaml
library!"
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: Run `JuliaFormatter.jl` against Julia source files
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"]
Formatting
A considerable amount of effort has been put into making pre-commit-localupdate respect the original style and preserve the comments in the pre-commit configuration files. Although it is currently folding long strings (for example, in description lines) and enforcing block indentation for better readability.
Requirements
- ruamel.yaml
- requests
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pre_commit_localupdate-0.3.1.tar.gz.
File metadata
- Download URL: pre_commit_localupdate-0.3.1.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.6 CPython/3.12.3 Linux/6.8.0-101-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4661914c1c17827ca2773512d92c0fa0960b8c4a4933a957023aff6bc2a81be
|
|
| MD5 |
2c30b76e653b972cc5c2199f074dc52b
|
|
| BLAKE2b-256 |
c7046d852652077b397a6654bc653452344ff420c5313984b0a2169774835056
|
File details
Details for the file pre_commit_localupdate-0.3.1-py3-none-any.whl.
File metadata
- Download URL: pre_commit_localupdate-0.3.1-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.6 CPython/3.12.3 Linux/6.8.0-101-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ed5e4ac98eb2785b308e208911e0a39274f089e64a541944437d23fcfddd904
|
|
| MD5 |
14589c6bf6088c178cb623f9ff9f0c1e
|
|
| BLAKE2b-256 |
234603318f92118cfb685678b42638d4326fe5e5989fe988ba1c0ea6222e3ec7
|