bump-pydantic is a command-line tool designed to automatically convert Pydantic V1 codebases to Pydantic V2 syntax. It helps users migrate their models, validators, and settings from the old API to the new one, facilitating a smoother transition. The current version is 0.8.0, and it has a regular release cadence, with several minor versions released frequently to add new features and fix issues.
pip install bump-pydanticNo compatibility data collected yet for this library.
This quickstart demonstrates how to use `bump-pydantic` to convert a simple Pydantic V1 model to V2 syntax. It creates a temporary Python file, runs the tool on it, and then prints the modified content. In practice, you would run `bump-pydantic` directly from your terminal on your project's directory or specific files.
Before running: `git commit -am 'Pre-bump-pydantic backup'` or `bump-pydantic --diff .`
Ensure your code is valid Python and update `libcst` to its latest version (automatically handled by `bump-pydantic`'s dependencies). Simplify complex expressions if persistent issues occur.
After running, carefully review the diff or modified files. Consult the official Pydantic V2 migration guide for any edge cases or complex scenarios.
Update `bump-pydantic` to version 0.7.0 or newer. Manually convert `example='value'` to `examples=['value']` if using older versions or if the tool misses a conversion.
First, ensure your Python code is syntactically correct and can be run by the interpreter. If the code is valid, try updating `bump-pydantic` (which often brings updated `libcst` versions). If the issue persists, isolate the problematic code snippet and simplify it if possible, or report the issue to the `libcst` or `bump-pydantic` maintainers.
Double-check that you are running `bump-pydantic` on the correct directory or files that contain Pydantic V1 code. Verify that the files are not excluded by any `.bump-pydantic-ignore` or command-line ignore patterns. If you expect changes, manually review your code to confirm it indeed uses Pydantic V1 syntax.
Ensure you have installed the package correctly using `pip install bump-pydantic`. If using a virtual environment, activate it before running the command. If installed, you might need to specify the full path to the executable or ensure your PATH environment variable is set correctly.