refactor: migrate from bump2version to bump-my-version for version management

- Removed .bumpversion.cfg and integrated version management into pyproject.toml.
- Updated pre-commit hooks and dependencies for code formatting, linting, and type checking.
- Added new functionality to JSONSchemaMessageInstance for generating default values from JSON schema.
- Enhanced test coverage for the new default value generation feature.
This commit is contained in:
Xuwznln
2026-02-28 20:49:02 +08:00
parent c1e65915c2
commit 37010bdeb1
6 changed files with 316 additions and 57 deletions

View File

@@ -1,81 +1,77 @@
# MsgCenterPy pre-commit hooks
# All tool configs are centralised in pyproject.toml
repos:
# Code formatting
# ── Code formatting ───────────────────────────────────────────
- repo: https://github.com/psf/black
rev: 23.12.1
rev: 26.1.0
hooks:
- id: black
language_version: python3
args: ["--line-length=120"]
# Reads [tool.black] from pyproject.toml
# Import sorting
# ── Import sorting ────────────────────────────────────────────
- repo: https://github.com/pycqa/isort
rev: 5.13.2
rev: 6.1.0
hooks:
- id: isort
args: ["--profile", "black", "--multi-line", "3"]
# Reads [tool.isort] from pyproject.toml
# Linting
# ── Linting ───────────────────────────────────────────────────
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
rev: 7.3.0
hooks:
- id: flake8
args:
- "--max-line-length=200" # Allow longer lines after black formatting
- "--extend-ignore=E203,W503,F401,E402,E721,F841"
- "--exclude=build,dist,__pycache__,.mypy_cache,.pytest_cache,htmlcov,.idea,.vscode,docs/_build,msgcenterpy.egg-info"
additional_dependencies: ["Flake8-pyproject"]
# Reads [tool.flake8] from pyproject.toml via Flake8-pyproject
# Type checking
# ── Type checking ─────────────────────────────────────────────
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.19.1
hooks:
- id: mypy
additional_dependencies: [types-PyYAML, types-jsonschema, pydantic]
args: ["--ignore-missing-imports", "--disable-error-code=unused-ignore"]
files: "^(msgcenterpy/)" # Check both source code and tests
args: ["--config-file=pyproject.toml"]
files: "^(msgcenterpy/)"
additional_dependencies:
- "pydantic>=2.0"
- "types-PyYAML"
- "types-jsonschema"
# General pre-commit hooks
# ── Basic file checks ────────────────────────────────────────
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v6.0.0
hooks:
# File checks
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: end-of-file-fixer
- id: check-yaml
- id: check-json
- id: check-toml
- id: check-xml
# Security
- id: check-merge-conflict
- id: check-case-conflict
- id: check-symlinks
- id: check-added-large-files
args: ["--maxkb=1000"]
# Python specific
- id: check-ast
- id: debug-statements
- id: name-tests-test
args: ["--django"]
args: ["--pytest-test-first"]
# Security scanning
# ── Security scanning ────────────────────────────────────────
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
rev: 1.9.3
hooks:
- id: bandit
args: ["-c", "pyproject.toml"]
additional_dependencies: ["bandit[toml]", "pbr"]
exclude: "^tests/"
exclude: "^(tests/)"
# YAML/JSON formatting
# ── YAML/JSON/Markdown formatting ────────────────────────────
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
types_or: [yaml, json, markdown]
exclude: "^(build/|dist/|__pycache__/|\\.mypy_cache/|\\.pytest_cache/|htmlcov/|\\.idea/|\\.vscode/|docs/_build/|msgcenterpy\\.egg-info/)"
exclude: "^(build/|dist/|__pycache__/|\\.mypy_cache/|\\.pytest_cache/|htmlcov/|\\.vscode/|docs/_build/|msgcenterpy\\.egg-info/)"
# Global settings
default_stages: [pre-commit, pre-push]
default_stages: [pre-commit]
fail_fast: false