from bumpversion.files import ConfiguredFile
from bumpversion.version_part import Version
-from bumpversion.config import Config , update_config_file
+from bumpversion.config import Config
+from bumpversion.config.files import update_config_file , update_ini_config_file
from bumpversion.exceptions import ConfigurationError
from bumpversion.utils import get_context , key_val_string
@@ -318,7 +323,10 @@ Source code for bumpversion.bump
configured_files = resolve_file_config ( config . files_to_modify , config . version_config )
modify_files ( configured_files , version , next_version , ctx , dry_run )
- update_config_file ( config_file , config . current_version , next_version_str , dry_run )
+ if config_file and config_file . suffix in { ".cfg" , ".ini" }:
+ update_ini_config_file ( config_file , config . current_version , next_version_str , dry_run )
+ else :
+ update_config_file ( config_file , config , version , next_version , ctx , dry_run )
ctx = get_context ( config , version , next_version )
ctx [ "new_version" ] = next_version_str
diff --git a/_modules/bumpversion/config.html b/_modules/bumpversion/config.html
index ef17678a..2a730d69 100644
--- a/_modules/bumpversion/config.html
+++ b/_modules/bumpversion/config.html
@@ -176,27 +176,31 @@
Version parts
Search and replace configuration
bumpversion
Toggle navigation of bumpversion
-
Explanation Toggle navigation of Explanation
+Explanation Toggle navigation of Explanation
Contributing to Bump My Version
@@ -238,127 +242,18 @@ Source code for bumpversion.config
"""Configuration management."""
from __future__ import annotations
-import glob
-import itertools
import logging
-import re
-from difflib import context_diff
-from pathlib import Path
-from typing import TYPE_CHECKING , Any , Dict , List , Optional , Union
+from typing import TYPE_CHECKING , Union
-from bumpversion.ui import print_warning
-from bumpversion.utils import labels_for_format
+from bumpversion.config.files import read_config_file
+from bumpversion.config.models import Config
+from bumpversion.exceptions import ConfigurationError
if TYPE_CHECKING : # pragma: no-coverage
- from bumpversion.scm import SCMInfo
- from bumpversion.version_part import VersionConfig
-
-from pydantic import BaseModel , Field
-from pydantic_settings import BaseSettings , SettingsConfigDict
-
-from bumpversion.exceptions import ConfigurationError
+ from pathlib import Path
logger = logging . getLogger ( __name__ )
-
-[docs] class VersionPartConfig ( BaseModel ):
-
"""Configuration of a part of the version."""
-
-
values : Optional [ list ] = None # Optional. Numeric is used if missing or no items in list
-
optional_value : Optional [ str ] = None # Optional.
-
# Defaults to first value. 0 in the case of numeric. Empty string means nothing is optional.
-
first_value : Union [ str , int , None ] = None # Optional. Defaults to first value in values
-
independent : bool = False
-
-
-[docs] class FileConfig ( BaseModel ):
-
"""Search and replace file config."""
-
-
filename : Optional [ str ] = None
-
glob : Optional [ str ] = None # Conflicts with filename. If both are specified, glob wins
-
parse : Optional [ str ] = None # If different from outer scope
-
serialize : Optional [ List [ str ]] = None # If different from outer scope
-
search : Optional [ str ] = None # If different from outer scope
-
replace : Optional [ str ] = None # If different from outer scope
-
regex : Optional [ bool ] = None # If different from outer scope
-
ignore_missing_version : Optional [ bool ] = None
-
-
-[docs] class Config ( BaseSettings ):
-
"""Bump Version configuration."""
-
-
current_version : Optional [ str ]
-
parse : str
-
serialize : List [ str ] = Field ( min_length = 1 )
-
search : str
-
replace : str
-
regex : bool
-
ignore_missing_version : bool
-
tag : bool
-
sign_tags : bool
-
tag_name : str
-
tag_message : Optional [ str ]
-
allow_dirty : bool
-
commit : bool
-
message : str
-
commit_args : Optional [ str ]
-
scm_info : Optional [ "SCMInfo" ]
-
parts : Dict [ str , VersionPartConfig ]
-
files : List [ FileConfig ]
-
included_paths : List [ str ] = Field ( default_factory = list )
-
excluded_paths : List [ str ] = Field ( default_factory = list )
-
model_config = SettingsConfigDict ( env_prefix = "bumpversion_" )
-
-
[docs] def add_files ( self , filename : Union [ str , List [ str ]]) -> None :
-
"""Add a filename to the list of files."""
-
filenames = [ filename ] if isinstance ( filename , str ) else filename
-
for name in filenames :
-
if name in self . resolved_filemap :
-
continue
-
self . files . append (
-
FileConfig (
-
filename = name ,
-
glob = None ,
-
parse = self . parse ,
-
serialize = self . serialize ,
-
search = self . search ,
-
replace = self . replace ,
-
regex = self . regex ,
-
ignore_missing_version = self . ignore_missing_version ,
-
)
-
)
-
-
@property
-
def resolved_filemap ( self ) -> Dict [ str , FileConfig ]:
-
"""Return a map of filenames to file configs, expanding any globs."""
-
new_files = []
-
for file_cfg in self . files :
-
if file_cfg . glob :
-
new_files . extend ( get_glob_files ( file_cfg ))
-
else :
-
new_files . append ( file_cfg )
-
-
return { file_cfg . filename : file_cfg for file_cfg in new_files }
-
-
@property
-
def files_to_modify ( self ) -> List [ FileConfig ]:
-
"""Return a list of files to modify."""
-
files_not_excluded = [
-
file_cfg . filename
-
for file_cfg in self . resolved_filemap . values ()
-
if file_cfg . filename not in self . excluded_paths
-
]
-
inclusion_set = set ( self . included_paths ) | set ( files_not_excluded )
-
return [ file_cfg for file_cfg in self . resolved_filemap . values () if file_cfg . filename in inclusion_set ]
-
-
@property
-
def version_config ( self ) -> "VersionConfig" :
-
"""Return the version configuration."""
-
from bumpversion.version_part import VersionConfig
-
-
return VersionConfig ( self . parse , self . serialize , self . search , self . replace , self . parts )
-
-
DEFAULTS = {
"current_version" : None ,
"parse" : r "(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)" ,
@@ -380,29 +275,6 @@ Source code for bumpversion.config
"files" : [],
}
-CONFIG_FILE_SEARCH_ORDER = (
- Path ( ".bumpversion.cfg" ),
- Path ( ".bumpversion.toml" ),
- Path ( "setup.cfg" ),
- Path ( "pyproject.toml" ),
-)
-
-
-[docs] def get_all_file_configs ( config_dict : dict ) -> List [ FileConfig ]:
-
"""Make sure all version parts are included."""
-
defaults = {
-
"parse" : config_dict [ "parse" ],
-
"serialize" : config_dict [ "serialize" ],
-
"search" : config_dict [ "search" ],
-
"replace" : config_dict [ "replace" ],
-
"ignore_missing_version" : config_dict [ "ignore_missing_version" ],
-
"regex" : config_dict [ "regex" ],
-
}
-
files = [{ k : v for k , v in filecfg . items () if v is not None } for filecfg in config_dict [ "files" ]]
-
for f in files :
-
f . update ({ k : v for k , v in defaults . items () if k not in f })
-
return [ FileConfig ( ** f ) for f in files ]
-
[docs] def get_configuration ( config_file : Union [ str , Path , None ] = None , ** overrides ) -> Config :
"""
@@ -415,6 +287,7 @@
Source code for bumpversion.config
Returns:
The configuration
"""
+ from bumpversion.config.utils import get_all_file_configs , get_all_part_configs
from bumpversion.scm import SCMInfo , SourceCodeManager , get_scm_info # noqa: F401
config_dict = DEFAULTS . copy ()
@@ -437,8 +310,7 @@ Source code for bumpversion.config
config = Config ( ** config_dict ) # type: ignore[arg-type]
# Get the information about the SCM
- tag_pattern = config . tag_name . replace ( " {new_version} " , "*" )
- scm_info = get_scm_info ( tag_pattern )
+ scm_info = get_scm_info ( config . tag_name , config . parse )
config . scm_info = scm_info
# Update and verify the current_version
@@ -447,17 +319,6 @@ Source code for bumpversion.config
-[docs] def get_all_part_configs ( config_dict : dict ) -> Dict [ str , VersionPartConfig ]:
-
"""Make sure all version parts are included."""
-
serialize = config_dict [ "serialize" ]
-
parts = config_dict [ "parts" ]
-
all_labels = set ( itertools . chain . from_iterable ([ labels_for_format ( fmt ) for fmt in serialize ]))
-
return {
-
label : VersionPartConfig ( ** parts [ label ]) if label in parts else VersionPartConfig () # type: ignore[call-arg]
-
for label in all_labels
-
}
-
-
[docs] def check_current_version ( config : Config ) -> str :
"""
Returns the current version.
@@ -490,221 +351,6 @@
Source code for bumpversion.config
return current_version
raise ConfigurationError ( "Unable to determine the current version." )
-
-
-
[docs] def find_config_file ( explicit_file : Union [ str , Path , None ] = None ) -> Union [ Path , None ]:
-
"""
-
Find the configuration file, if it exists.
-
-
If no explicit configuration file is passed, it will search in several files to
-
find its configuration.
-
-
Args:
-
explicit_file: The configuration file to explicitly use.
-
-
Returns:
-
The configuration file path
-
"""
-
search_paths = [ Path ( explicit_file )] if explicit_file else CONFIG_FILE_SEARCH_ORDER
-
return next (
-
( cfg_file for cfg_file in search_paths if cfg_file . exists () and "bumpversion]" in cfg_file . read_text ()),
-
None ,
-
)
-
-
-
[docs] def read_config_file ( config_file : Union [ str , Path , None ] = None ) -> Dict [ str , Any ]:
-
"""
-
Read the configuration file, if it exists.
-
-
If no explicit configuration file is passed, it will search in several files to
-
find its configuration.
-
-
Args:
-
config_file: The configuration file to explicitly use.
-
-
Returns:
-
A dictionary of read key-values
-
"""
-
if not config_file :
-
logger . info ( "No configuration file found." )
-
return {}
-
-
logger . info ( "Reading config file %s :" , config_file )
-
config_path = Path ( config_file )
-
if config_path . suffix == ".cfg" :
-
print_warning ( "The .cfg file format is deprecated. Please use .toml instead." )
-
return read_ini_file ( config_path )
-
elif config_path . suffix == ".toml" :
-
return read_toml_file ( config_path )
-
return {}
-
-
-
[docs] def read_ini_file ( file_path : Path ) -> Dict [ str , Any ]: # noqa: C901
-
"""
-
Parse an INI file and return a dictionary of sections and their options.
-
-
Args:
-
file_path: The path to the INI file.
-
-
Returns:
-
dict: A dictionary of sections and their options.
-
"""
-
import configparser
-
-
from bumpversion import autocast
-
-
# Create a ConfigParser object and read the INI file
-
config_parser = configparser . RawConfigParser ()
-
if file_path . name == "setup.cfg" :
-
config_parser = configparser . ConfigParser ()
-
-
config_parser . read ( file_path )
-
-
# Create an empty dictionary to hold the parsed sections and options
-
bumpversion_options : Dict [ str , Any ] = { "files" : [], "parts" : {}}
-
-
# Loop through each section in the INI file
-
for section_name in config_parser . sections ():
-
if not section_name . startswith ( "bumpversion" ):
-
continue
-
-
section_parts = section_name . split ( ":" )
-
num_parts = len ( section_parts )
-
options = { key : autocast . autocast_value ( val ) for key , val in config_parser . items ( section_name )}
-
-
if num_parts == 1 : # bumpversion section
-
bumpversion_options . update ( options )
-
serialize = bumpversion_options . get ( "serialize" , [])
-
if "message" in bumpversion_options and isinstance ( bumpversion_options [ "message" ], list ):
-
bumpversion_options [ "message" ] = "," . join ( bumpversion_options [ "message" ])
-
if not isinstance ( serialize , list ):
-
bumpversion_options [ "serialize" ] = [ serialize ]
-
elif num_parts > 1 and section_parts [ 1 ] . startswith ( "file" ):
-
file_options = {
-
"filename" : section_parts [ 2 ],
-
}
-
file_options . update ( options )
-
if "replace" in file_options and isinstance ( file_options [ "replace" ], list ):
-
file_options [ "replace" ] = " \n " . join ( file_options [ "replace" ])
-
bumpversion_options [ "files" ] . append ( file_options )
-
elif num_parts > 1 and section_parts [ 1 ] . startswith ( "glob" ):
-
file_options = {
-
"glob" : section_parts [ 2 ],
-
}
-
file_options . update ( options )
-
if "replace" in file_options and isinstance ( file_options [ "replace" ], list ):
-
file_options [ "replace" ] = " \n " . join ( file_options [ "replace" ])
-
bumpversion_options [ "files" ] . append ( file_options )
-
elif num_parts > 1 and section_parts [ 1 ] . startswith ( "part" ):
-
bumpversion_options [ "parts" ][ section_parts [ 2 ]] = options
-
-
# Return the dictionary of sections and options
-
return bumpversion_options
-
-
-
[docs] def read_toml_file ( file_path : Path ) -> Dict [ str , Any ]:
-
"""
-
Parse a TOML file and return the `bumpversion` section.
-
-
Args:
-
file_path: The path to the TOML file.
-
-
Returns:
-
dict: A dictionary of the `bumpversion` section.
-
"""
-
import tomlkit
-
-
# Load the TOML file
-
toml_data = tomlkit . parse ( file_path . read_text ()) . unwrap ()
-
-
return toml_data . get ( "tool" , {}) . get ( "bumpversion" , {})
-
-
-
[docs] def update_config_file (
-
config_file : Union [ str , Path , None ], current_version : str , new_version : str , dry_run : bool = False
-
) -> None :
-
"""
-
Update the current_version key in the configuration file.
-
-
If no explicit configuration file is passed, it will search in several files to
-
find its configuration.
-
-
Instead of parsing and re-writing the config file with new information, it will use
-
a regular expression to just replace the current_version value. The idea is it will
-
avoid unintentional changes (like formatting) to the config file.
-
-
Args:
-
config_file: The configuration file to explicitly use.
-
current_version: The serialized current version.
-
new_version: The serialized new version.
-
dry_run: True if the update should be a dry run.
-
"""
-
toml_current_version_regex = re . compile (
-
f '(?P<section_prefix> \\ [tool \\ .bumpversion] \n [^[]*current_version \\ s*= \\ s*)( \\ " { current_version } \\ ")' ,
-
re . MULTILINE ,
-
)
-
cfg_current_version_regex = re . compile (
-
f "(?P<section_prefix> \\ [bumpversion] \n [^[]*current_version \\ s*= \\ s*)(?P<version> { current_version } )" ,
-
re . MULTILINE ,
-
)
-
-
if not config_file :
-
logger . info ( "No configuration file found to update." )
-
return
-
-
config_path = Path ( config_file )
-
existing_config = config_path . read_text ()
-
if config_path . suffix == ".cfg" and cfg_current_version_regex . search ( existing_config ):
-
sub_str = f " \\ g<section_prefix> { new_version } "
-
new_config = cfg_current_version_regex . sub ( sub_str , existing_config )
-
elif config_path . suffix == ".toml" and toml_current_version_regex . search ( existing_config ):
-
sub_str = f ' \\ g<section_prefix>" { new_version } "'
-
new_config = toml_current_version_regex . sub ( sub_str , existing_config )
-
else :
-
logger . info ( "Could not find the current version in the config file: %s ." , config_path )
-
return
-
-
logger . info (
-
" %s to config file %s :" ,
-
"Would write" if dry_run else "Writing" ,
-
config_path ,
-
)
-
-
logger . info (
-
" \n " . join (
-
list (
-
context_diff (
-
existing_config . splitlines (),
-
new_config . splitlines (),
-
fromfile = f "before { config_path } " ,
-
tofile = f "after { config_path } " ,
-
lineterm = "" ,
-
)
-
)
-
)
-
)
-
-
if not dry_run :
-
config_path . write_text ( new_config )
-
-
-
[docs] def get_glob_files ( file_cfg : FileConfig ) -> List [ FileConfig ]:
-
"""
-
Return a list of files that match the glob pattern.
-
-
Args:
-
file_cfg: The file configuration containing the glob pattern
-
-
Returns:
-
A list of resolved file configurations according to the pattern.
-
"""
-
files = []
-
for filename_glob in glob . glob ( file_cfg . glob , recursive = True ):
-
new_file_cfg = file_cfg . copy ()
-
new_file_cfg . filename = filename_glob
-
new_file_cfg . glob = None
-
files . append ( new_file_cfg )
-
return files
diff --git a/_modules/bumpversion/config/files.html b/_modules/bumpversion/config/files.html
new file mode 100644
index 00000000..545f0718
--- /dev/null
+++ b/_modules/bumpversion/config/files.html
@@ -0,0 +1,541 @@
+
+
+
+
+
+
+
+ bumpversion.config.files - Bump My Version 0.12.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Contents
+
+
+
+
+
+
+ Expand
+
+
+
+
+
+ Light mode
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Dark mode
+
+
+
+
+
+
+ Auto light/dark mode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Hide table of contents sidebar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Back to top
+
+
+
+
+ Toggle Light / Dark / Auto color theme
+
+
+
+
+
+
+ Toggle table of contents sidebar
+
+
+
+
+ Source code for bumpversion.config.files
+"""Contains methods for finding and reading configuration files."""
+
+from __future__ import annotations
+
+import logging
+import re
+from difflib import context_diff
+from pathlib import Path
+from typing import TYPE_CHECKING , Any , Dict , MutableMapping , Union
+
+from bumpversion.ui import print_warning
+
+if TYPE_CHECKING : # pragma: no-coverage
+ from bumpversion.config.models import Config
+ from bumpversion.version_part import Version
+
+logger = logging . getLogger ( __name__ )
+
+CONFIG_FILE_SEARCH_ORDER = (
+ Path ( ".bumpversion.cfg" ),
+ Path ( ".bumpversion.toml" ),
+ Path ( "setup.cfg" ),
+ Path ( "pyproject.toml" ),
+)
+
+
+[docs] def find_config_file ( explicit_file : Union [ str , Path , None ] = None ) -> Union [ Path , None ]:
+
"""
+
Find the configuration file, if it exists.
+
+
If no explicit configuration file is passed, it will search in several files to
+
find its configuration.
+
+
Args:
+
explicit_file: The configuration file to explicitly use.
+
+
Returns:
+
The configuration file path
+
"""
+
search_paths = [ Path ( explicit_file )] if explicit_file else CONFIG_FILE_SEARCH_ORDER
+
return next (
+
( cfg_file for cfg_file in search_paths if cfg_file . exists () and "bumpversion]" in cfg_file . read_text ()),
+
None ,
+
)
+
+
+[docs] def read_config_file ( config_file : Union [ str , Path , None ] = None ) -> Dict [ str , Any ]:
+
"""
+
Read the configuration file, if it exists.
+
+
If no explicit configuration file is passed, it will search in several files to
+
find its configuration.
+
+
Args:
+
config_file: The configuration file to explicitly use.
+
+
Returns:
+
A dictionary of read key-values
+
"""
+
if not config_file :
+
logger . info ( "No configuration file found." )
+
return {}
+
+
logger . info ( "Reading config file %s :" , config_file )
+
config_path = Path ( config_file )
+
if config_path . suffix == ".cfg" :
+
print_warning ( "The .cfg file format is deprecated. Please use .toml instead." )
+
return read_ini_file ( config_path )
+
elif config_path . suffix == ".toml" :
+
return read_toml_file ( config_path )
+
return {}
+
+
+[docs] def read_ini_file ( file_path : Path ) -> Dict [ str , Any ]: # noqa: C901
+
"""
+
Parse an INI file and return a dictionary of sections and their options.
+
+
Args:
+
file_path: The path to the INI file.
+
+
Returns:
+
dict: A dictionary of sections and their options.
+
"""
+
import configparser
+
+
from bumpversion import autocast
+
+
# Create a ConfigParser object and read the INI file
+
config_parser = configparser . RawConfigParser ()
+
if file_path . name == "setup.cfg" :
+
config_parser = configparser . ConfigParser ()
+
+
config_parser . read ( file_path )
+
+
# Create an empty dictionary to hold the parsed sections and options
+
bumpversion_options : Dict [ str , Any ] = { "files" : [], "parts" : {}}
+
+
# Loop through each section in the INI file
+
for section_name in config_parser . sections ():
+
if not section_name . startswith ( "bumpversion" ):
+
continue
+
+
section_parts = section_name . split ( ":" )
+
num_parts = len ( section_parts )
+
options = { key : autocast . autocast_value ( val ) for key , val in config_parser . items ( section_name )}
+
+
if num_parts == 1 : # bumpversion section
+
bumpversion_options . update ( options )
+
serialize = bumpversion_options . get ( "serialize" , [])
+
if "message" in bumpversion_options and isinstance ( bumpversion_options [ "message" ], list ):
+
bumpversion_options [ "message" ] = "," . join ( bumpversion_options [ "message" ])
+
if not isinstance ( serialize , list ):
+
bumpversion_options [ "serialize" ] = [ serialize ]
+
elif num_parts > 1 and section_parts [ 1 ] . startswith ( "file" ):
+
file_options = {
+
"filename" : section_parts [ 2 ],
+
}
+
file_options . update ( options )
+
if "replace" in file_options and isinstance ( file_options [ "replace" ], list ):
+
file_options [ "replace" ] = " \n " . join ( file_options [ "replace" ])
+
bumpversion_options [ "files" ] . append ( file_options )
+
elif num_parts > 1 and section_parts [ 1 ] . startswith ( "glob" ):
+
file_options = {
+
"glob" : section_parts [ 2 ],
+
}
+
file_options . update ( options )
+
if "replace" in file_options and isinstance ( file_options [ "replace" ], list ):
+
file_options [ "replace" ] = " \n " . join ( file_options [ "replace" ])
+
bumpversion_options [ "files" ] . append ( file_options )
+
elif num_parts > 1 and section_parts [ 1 ] . startswith ( "part" ):
+
bumpversion_options [ "parts" ][ section_parts [ 2 ]] = options
+
+
# Return the dictionary of sections and options
+
return bumpversion_options
+
+
+[docs] def read_toml_file ( file_path : Path ) -> Dict [ str , Any ]:
+
"""
+
Parse a TOML file and return the `bumpversion` section.
+
+
Args:
+
file_path: The path to the TOML file.
+
+
Returns:
+
dict: A dictionary of the `bumpversion` section.
+
"""
+
import tomlkit
+
+
# Load the TOML file
+
toml_data = tomlkit . parse ( file_path . read_text ()) . unwrap ()
+
+
return toml_data . get ( "tool" , {}) . get ( "bumpversion" , {})
+
+
+[docs] def update_config_file (
+
config_file : Union [ str , Path ],
+
config : Config ,
+
current_version : Version ,
+
new_version : Version ,
+
context : MutableMapping ,
+
dry_run : bool = False ,
+
) -> None :
+
"""
+
Update the current_version key in the configuration file.
+
+
Args:
+
config_file: The configuration file to explicitly use.
+
config: The configuration to use.
+
current_version: The current version.
+
new_version: The new version.
+
context: The context to use for serialization.
+
dry_run: True if the update should be a dry run.
+
"""
+
from bumpversion.config.models import FileConfig
+
from bumpversion.files import DataFileUpdater
+
+
if not config_file :
+
logger . info ( "No configuration file found to update." )
+
return
+
+
config_path = Path ( config_file )
+
if config_path . suffix != ".toml" :
+
logger . info ( "Could not find the current version in the config file: %s ." , config_path )
+
return
+
+
# TODO: Eventually this should be transformed into another default "files_to_modify" entry
+
datafile_config = FileConfig (
+
filename = str ( config_path ),
+
key_path = "tool.bumpversion.current_version" ,
+
search = config . search ,
+
replace = config . replace ,
+
regex = config . regex ,
+
ignore_missing_version = config . ignore_missing_version ,
+
serialize = config . serialize ,
+
parse = config . parse ,
+
)
+
+
updater = DataFileUpdater ( datafile_config , config . version_config . part_configs )
+
updater . update_file ( current_version , new_version , context , dry_run )
+
+
+[docs] def update_ini_config_file (
+
config_file : Union [ str , Path ], current_version : str , new_version : str , dry_run : bool = False
+
) -> None :
+
"""
+
Update the current_version key in the configuration file.
+
+
Instead of parsing and re-writing the config file with new information, it will use
+
a regular expression to just replace the current_version value. The idea is it will
+
avoid unintentional changes (like formatting) to the config file.
+
+
Args:
+
config_file: The configuration file to explicitly use.
+
current_version: The serialized current version.
+
new_version: The serialized new version.
+
dry_run: True if the update should be a dry run.
+
"""
+
cfg_current_version_regex = re . compile (
+
f "(?P<section_prefix> \\ [bumpversion] \n [^[]*current_version \\ s*= \\ s*)(?P<version> { current_version } )" ,
+
re . MULTILINE ,
+
)
+
+
config_path = Path ( config_file )
+
existing_config = config_path . read_text ()
+
if config_path . suffix == ".cfg" and cfg_current_version_regex . search ( existing_config ):
+
sub_str = f " \\ g<section_prefix> { new_version } "
+
new_config = cfg_current_version_regex . sub ( sub_str , existing_config )
+
else :
+
logger . info ( "Could not find the current version in the config file: %s ." , config_path )
+
return
+
+
logger . info (
+
" %s to config file %s :" ,
+
"Would write" if dry_run else "Writing" ,
+
config_path ,
+
)
+
+
logger . info (
+
" \n " . join (
+
list (
+
context_diff (
+
existing_config . splitlines (),
+
new_config . splitlines (),
+
fromfile = f "before { config_path } " ,
+
tofile = f "after { config_path } " ,
+
lineterm = "" ,
+
)
+
)
+
)
+
)
+
+
if not dry_run :
+
config_path . write_text ( new_config )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/_modules/bumpversion/config/models.html b/_modules/bumpversion/config/models.html
new file mode 100644
index 00000000..c726daff
--- /dev/null
+++ b/_modules/bumpversion/config/models.html
@@ -0,0 +1,401 @@
+
+
+
+
+
+
+
+ bumpversion.config.models - Bump My Version 0.12.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Contents
+
+
+
+
+
+
+ Expand
+
+
+
+
+
+ Light mode
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Dark mode
+
+
+
+
+
+
+ Auto light/dark mode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Hide table of contents sidebar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Back to top
+
+
+
+
+ Toggle Light / Dark / Auto color theme
+
+
+
+
+
+
+ Toggle table of contents sidebar
+
+
+
+
+ Source code for bumpversion.config.models
+"""Bump My Version configuration models."""
+from __future__ import annotations
+
+from typing import TYPE_CHECKING , Dict , List , Optional , Union
+
+from pydantic import BaseModel , Field
+from pydantic_settings import BaseSettings , SettingsConfigDict
+
+if TYPE_CHECKING :
+ from bumpversion.scm import SCMInfo
+ from bumpversion.version_part import VersionConfig
+
+
+[docs] class VersionPartConfig ( BaseModel ):
+
"""Configuration of a part of the version."""
+
+
values : Optional [ list ] = None # Optional. Numeric is used if missing or no items in list
+
optional_value : Optional [ str ] = None # Optional.
+
# Defaults to first value. 0 in the case of numeric. Empty string means nothing is optional.
+
first_value : Union [ str , int , None ] = None # Optional. Defaults to first value in values
+
independent : bool = False
+
+
+[docs] class FileConfig ( BaseModel ):
+
"""Search and replace file config."""
+
+
parse : str
+
serialize : List [ str ]
+
search : str
+
replace : str
+
regex : bool
+
ignore_missing_version : bool
+
filename : Optional [ str ] = None
+
glob : Optional [ str ] = None # Conflicts with filename. If both are specified, glob wins
+
key_path : Optional [ str ] = None # If specified, and has an appropriate extension, will be treated as a data file
+
+
+[docs] class Config ( BaseSettings ):
+
"""Bump Version configuration."""
+
+
current_version : Optional [ str ]
+
parse : str
+
serialize : List [ str ] = Field ( min_length = 1 )
+
search : str
+
replace : str
+
regex : bool
+
ignore_missing_version : bool
+
tag : bool
+
sign_tags : bool
+
tag_name : str
+
tag_message : Optional [ str ]
+
allow_dirty : bool
+
commit : bool
+
message : str
+
commit_args : Optional [ str ]
+
scm_info : Optional [ "SCMInfo" ]
+
parts : Dict [ str , VersionPartConfig ]
+
files : List [ FileConfig ]
+
included_paths : List [ str ] = Field ( default_factory = list )
+
excluded_paths : List [ str ] = Field ( default_factory = list )
+
model_config = SettingsConfigDict ( env_prefix = "bumpversion_" )
+
+
[docs] def add_files ( self , filename : Union [ str , List [ str ]]) -> None :
+
"""Add a filename to the list of files."""
+
filenames = [ filename ] if isinstance ( filename , str ) else filename
+
for name in filenames :
+
if name in self . resolved_filemap :
+
continue
+
self . files . append (
+
FileConfig (
+
filename = name ,
+
glob = None ,
+
key_path = None ,
+
parse = self . parse ,
+
serialize = self . serialize ,
+
search = self . search ,
+
replace = self . replace ,
+
regex = self . regex ,
+
ignore_missing_version = self . ignore_missing_version ,
+
)
+
)
+
+
@property
+
def resolved_filemap ( self ) -> Dict [ str , FileConfig ]:
+
"""Return a map of filenames to file configs, expanding any globs."""
+
from bumpversion.config.utils import resolve_glob_files
+
+
new_files = []
+
for file_cfg in self . files :
+
if file_cfg . glob :
+
new_files . extend ( resolve_glob_files ( file_cfg ))
+
else :
+
new_files . append ( file_cfg )
+
+
return { file_cfg . filename : file_cfg for file_cfg in new_files }
+
+
@property
+
def files_to_modify ( self ) -> List [ FileConfig ]:
+
"""Return a list of files to modify."""
+
files_not_excluded = [
+
file_cfg . filename
+
for file_cfg in self . resolved_filemap . values ()
+
if file_cfg . filename not in self . excluded_paths
+
]
+
inclusion_set = set ( self . included_paths ) | set ( files_not_excluded )
+
return [ file_cfg for file_cfg in self . resolved_filemap . values () if file_cfg . filename in inclusion_set ]
+
+
@property
+
def version_config ( self ) -> "VersionConfig" :
+
"""Return the version configuration."""
+
from bumpversion.version_part import VersionConfig
+
+
return VersionConfig ( self . parse , self . serialize , self . search , self . replace , self . parts )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/_modules/bumpversion/config/utils.html b/_modules/bumpversion/config/utils.html
new file mode 100644
index 00000000..bb7ccf42
--- /dev/null
+++ b/_modules/bumpversion/config/utils.html
@@ -0,0 +1,343 @@
+
+
+
+
+
+
+
+ bumpversion.config.utils - Bump My Version 0.12.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Contents
+
+
+
+
+
+
+ Expand
+
+
+
+
+
+ Light mode
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Dark mode
+
+
+
+
+
+
+ Auto light/dark mode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Hide table of contents sidebar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Back to top
+
+
+
+
+ Toggle Light / Dark / Auto color theme
+
+
+
+
+
+
+ Toggle table of contents sidebar
+
+
+
+
+ Source code for bumpversion.config.utils
+"""Helper functions for the config module."""
+from __future__ import annotations
+
+import glob
+import itertools
+from typing import Dict , List
+
+from bumpversion.config.models import FileConfig , VersionPartConfig
+from bumpversion.utils import labels_for_format
+
+
+[docs] def get_all_file_configs ( config_dict : dict ) -> List [ FileConfig ]:
+
"""Make sure all version parts are included."""
+
defaults = {
+
"parse" : config_dict [ "parse" ],
+
"serialize" : config_dict [ "serialize" ],
+
"search" : config_dict [ "search" ],
+
"replace" : config_dict [ "replace" ],
+
"ignore_missing_version" : config_dict [ "ignore_missing_version" ],
+
"regex" : config_dict [ "regex" ],
+
}
+
files = [{ k : v for k , v in filecfg . items () if v is not None } for filecfg in config_dict [ "files" ]]
+
for f in files :
+
f . update ({ k : v for k , v in defaults . items () if k not in f })
+
return [ FileConfig ( ** f ) for f in files ]
+
+
+[docs] def get_all_part_configs ( config_dict : dict ) -> Dict [ str , VersionPartConfig ]:
+
"""Make sure all version parts are included."""
+
serialize = config_dict [ "serialize" ]
+
parts = config_dict [ "parts" ]
+
all_labels = set ( itertools . chain . from_iterable ([ labels_for_format ( fmt ) for fmt in serialize ]))
+
return {
+
label : VersionPartConfig ( ** parts [ label ]) if label in parts else VersionPartConfig () # type: ignore[call-arg]
+
for label in all_labels
+
}
+
+
+[docs] def resolve_glob_files ( file_cfg : FileConfig ) -> List [ FileConfig ]:
+
"""
+
Return a list of file configurations that match the glob pattern.
+
+
Args:
+
file_cfg: The file configuration containing the glob pattern
+
+
Returns:
+
A list of resolved file configurations according to the pattern.
+
"""
+
files = []
+
for filename_glob in glob . glob ( file_cfg . glob , recursive = True ):
+
new_file_cfg = file_cfg . model_copy ()
+
new_file_cfg . filename = filename_glob
+
new_file_cfg . glob = None
+
files . append ( new_file_cfg )
+
return files
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/_modules/bumpversion/exceptions.html b/_modules/bumpversion/exceptions.html
index d5182c0d..78e81874 100644
--- a/_modules/bumpversion/exceptions.html
+++ b/_modules/bumpversion/exceptions.html
@@ -176,27 +176,31 @@
Version parts
Search and replace configuration
bumpversion
Toggle navigation of bumpversion
-
Explanation Toggle navigation of Explanation
-
Explanation Toggle navigation of Explanation
+Explanation Toggle navigation of Explanation
Contributing to Bump My Version
@@ -240,15 +244,94 @@ Source code for bumpversion.files
import re
from copy import deepcopy
from difflib import context_diff
-from typing import List , MutableMapping , Optional , Tuple
+from pathlib import Path
+from typing import Dict , List , MutableMapping , Optional , Tuple
-from bumpversion.config import FileConfig
+from bumpversion.config.models import FileConfig , VersionPartConfig
from bumpversion.exceptions import VersionNotFoundError
from bumpversion.version_part import Version , VersionConfig
logger = logging . getLogger ( __name__ )
+[docs] def get_search_pattern ( search_str : str , context : MutableMapping , use_regex : bool = False ) -> Tuple [ re . Pattern , str ]:
+
"""
+
Render the search pattern and return the compiled regex pattern and the raw pattern.
+
+
Args:
+
search_str: A string containing the search pattern as a format string
+
context: The context to use for rendering the search pattern
+
use_regex: If True, the search pattern is treated as a regex pattern
+
+
Returns:
+
A tuple of the compiled regex pattern and the raw pattern as a string.
+
"""
+
# the default search pattern is escaped, so we can still use it in a regex
+
raw_pattern = search_str . format ( ** context )
+
default = re . compile ( re . escape ( raw_pattern ), re . MULTILINE | re . DOTALL )
+
if not use_regex :
+
logger . debug ( "No RegEx flag detected. Searching for the default pattern: ' %s '" , default . pattern )
+
return default , raw_pattern
+
+
re_context = { key : re . escape ( str ( value )) for key , value in context . items ()}
+
regex_pattern = search_str . format ( ** re_context )
+
try :
+
search_for_re = re . compile ( regex_pattern , re . MULTILINE | re . DOTALL )
+
logger . debug ( "Searching for the regex: ' %s '" , search_for_re . pattern )
+
return search_for_re , raw_pattern
+
except re . error as e :
+
logger . error ( "Invalid regex ' %s ': %s ." , default , e )
+
+
logger . debug ( "Invalid regex. Searching for the default pattern: ' %s '" , raw_pattern )
+
return default , raw_pattern
+
+
+[docs] def contains_pattern ( search : re . Pattern , contents : str ) -> bool :
+
"""Does the search pattern match any part of the contents?"""
+
if not search or not contents :
+
return False
+
+
for m in re . finditer ( search , contents ):
+
line_no = contents . count ( " \n " , 0 , m . start ( 0 )) + 1
+
logger . info (
+
"Found ' %s ' at line %s : %s " ,
+
search ,
+
line_no ,
+
m . string [ m . start () : m . end ( 0 )],
+
)
+
return True
+
return False
+
+
+[docs] def log_changes ( file_path : str , file_content_before : str , file_content_after : str , dry_run : bool = False ) -> None :
+
"""
+
Log the changes that would be made to the file.
+
+
Args:
+
file_path: The path to the file
+
file_content_before: The file contents before the change
+
file_content_after: The file contents after the change
+
dry_run: True if this is a report-only job
+
"""
+
if file_content_before != file_content_after :
+
logger . info ( " %s file %s :" , "Would change" if dry_run else "Changing" , file_path )
+
logger . info (
+
" \n " . join (
+
list (
+
context_diff (
+
file_content_before . splitlines (),
+
file_content_after . splitlines (),
+
fromfile = f "before { file_path } " ,
+
tofile = f "after { file_path } " ,
+
lineterm = "" ,
+
)
+
)
+
)
+
)
+
else :
+
logger . info ( " %s file %s " , "Would not change" if dry_run else "Not changing" , file_path )
+
+
[docs] class ConfiguredFile :
"""A file to modify in a configured way."""
@@ -300,9 +383,9 @@
Source code for bumpversion.files
Returns:
True if the version number is in fact present.
"""
- search_expression , raw_search_expression = self . get_search_pattern ( context )
-
- if self . contains ( search_expression ):
+ search_expression , raw_search_expression = get_search_pattern ( self . search , context , self . regex )
+ file_contents = self . get_file_contents ()
+ if contains_pattern ( search_expression , file_contents ):
return True
# the `search` pattern did not match, but the original supplied
@@ -313,7 +396,7 @@ Source code for bumpversion.files
# very specific parts of the file
search_pattern_is_default = self . search == self . version_config . search
- if search_pattern_is_default and self . contains ( re . compile ( re . escape ( version . original ))):
+ if search_pattern_is_default and contains_pattern ( re . compile ( re . escape ( version . original )), file_contents ):
# The original version is present, and we're not looking for something
# more specific -> this is accepted as a match
return True
@@ -323,25 +406,6 @@ Source code for bumpversion.files
return False
raise VersionNotFoundError ( f "Did not find ' { raw_search_expression } ' in file: ' { self . path } '" )
-
-
[docs] def replace_version (
self , current_version : Version , new_version : Version , context : MutableMapping , dry_run : bool = False
) -> None :
@@ -352,7 +416,7 @@
Source code for bumpversion.files
if new_version :
context [ "new_version" ] = self . version_config . serialize ( new_version , context )
- search_for , raw_search_pattern = self . get_search_pattern ( context )
+ search_for , raw_search_pattern = get_search_pattern ( self . search , context , self . regex )
replace_with = self . version_config . replace . format ( ** context )
file_content_after = search_for . sub ( replace_with , file_content_before )
@@ -360,51 +424,14 @@ Source code for bumpversion.files
if file_content_before == file_content_after and current_version . original :
og_context = deepcopy ( context )
og_context [ "current_version" ] = current_version . original
- search_for_og , og_raw_search_pattern = self . get_search_pattern ( og_context )
+ search_for_og , og_raw_search_pattern = get_search_pattern ( self . search , og_context , self . regex )
file_content_after = search_for_og . sub ( replace_with , file_content_before )
- if file_content_before != file_content_after :
- logger . info ( " %s file %s :" , "Would change" if dry_run else "Changing" , self . path )
- logger . info (
- " \n " . join (
- list (
- context_diff (
- file_content_before . splitlines (),
- file_content_after . splitlines (),
- fromfile = f "before { self . path } " ,
- tofile = f "after { self . path } " ,
- lineterm = "" ,
- )
- )
- )
- )
- else :
- logger . info ( " %s file %s " , "Would not change" if dry_run else "Not changing" , self . path )
+ log_changes ( self . path , file_content_before , file_content_after , dry_run )
if not dry_run : # pragma: no-coverage
self . write_file_contents ( file_content_after )
-
-
@@ -463,6 +490,94 @@ Source code for bumpversion.files
for f in files :
context [ "current_version" ] = f . version_config . serialize ( current_version , context )
f . contains_version ( current_version , context )
+
+
+[docs] class FileUpdater :
+
"""A class to handle updating files."""
+
+
def __init__ (
+
self ,
+
file_cfg : FileConfig ,
+
version_config : VersionConfig ,
+
search : Optional [ str ] = None ,
+
replace : Optional [ str ] = None ,
+
) -> None :
+
self . path = file_cfg . filename
+
self . version_config = version_config
+
self . parse = file_cfg . parse or version_config . parse_regex . pattern
+
self . serialize = file_cfg . serialize or version_config . serialize_formats
+
self . search = search or file_cfg . search or version_config . search
+
self . replace = replace or file_cfg . replace or version_config . replace
+
self . regex = file_cfg . regex or False
+
self . ignore_missing_version = file_cfg . ignore_missing_version or False
+
self . version_config = VersionConfig (
+
self . parse , self . serialize , self . search , self . replace , version_config . part_configs
+
)
+
self . _newlines : Optional [ str ] = None
+
+
[docs] def update_file (
+
self , current_version : Version , new_version : Version , context : MutableMapping , dry_run : bool = False
+
) -> None :
+
"""Update the files."""
+
# TODO: Implement this
+
pass
+
+
+[docs] class DataFileUpdater :
+
"""A class to handle updating files."""
+
+
def __init__ (
+
self ,
+
file_cfg : FileConfig ,
+
version_part_configs : Dict [ str , VersionPartConfig ],
+
) -> None :
+
self . path = Path ( file_cfg . filename )
+
self . key_path = file_cfg . key_path
+
self . search = file_cfg . search
+
self . replace = file_cfg . replace
+
self . regex = file_cfg . regex
+
self . ignore_missing_version = file_cfg . ignore_missing_version
+
self . version_config = VersionConfig (
+
file_cfg . parse , file_cfg . serialize , file_cfg . search , file_cfg . replace , version_part_configs
+
)
+
+
[docs] def update_file (
+
self , current_version : Version , new_version : Version , context : MutableMapping , dry_run : bool = False
+
) -> None :
+
"""Update the files."""
+
new_context = deepcopy ( context )
+
new_context [ "current_version" ] = self . version_config . serialize ( current_version , context )
+
new_context [ "new_version" ] = self . version_config . serialize ( new_version , context )
+
search_for , raw_search_pattern = get_search_pattern ( self . search , new_context , self . regex )
+
replace_with = self . replace . format ( ** new_context )
+
if self . path . suffix == ".toml" :
+
self . _update_toml_file ( search_for , raw_search_pattern , replace_with , dry_run )
+
+
[docs] def _update_toml_file (
+
self , search_for : re . Pattern , raw_search_pattern : str , replace_with : str , dry_run : bool = False
+
) -> None :
+
"""Update a TOML file."""
+
import dotted
+
import tomlkit
+
+
toml_data = tomlkit . parse ( self . path . read_text ())
+
value_before = dotted . get ( toml_data , self . key_path )
+
+
if value_before is None :
+
raise KeyError ( f "Key path ' { self . key_path } ' does not exist in { self . path } " )
+
elif not contains_pattern ( search_for , value_before ) and not self . ignore_missing_version :
+
raise ValueError (
+
f "Key ' { self . key_path } ' in { self . path } does not contain the correct contents: { raw_search_pattern } "
+
)
+
+
new_value = search_for . sub ( replace_with , value_before )
+
log_changes ( f " { self . path } : { self . key_path } " , value_before , new_value , dry_run )
+
+
if dry_run :
+
return
+
+
dotted . update ( toml_data , self . key_path , new_value )
+
self . path . write_text ( tomlkit . dumps ( toml_data ))
diff --git a/_modules/bumpversion/functions.html b/_modules/bumpversion/functions.html
index 51e645cb..112ae5eb 100644
--- a/_modules/bumpversion/functions.html
+++ b/_modules/bumpversion/functions.html
@@ -176,27 +176,31 @@
Version parts
Search and replace configuration
bumpversion
Toggle navigation of bumpversion
-
Explanation Toggle navigation of Explanation
-
Explanation Toggle navigation of Explanation
+Explanation Toggle navigation of Explanation
Contributing to Bump My Version
@@ -246,6 +250,8 @@ Source code for bumpversion.scm
from tempfile import NamedTemporaryFile
from typing import TYPE_CHECKING , ClassVar , List , MutableMapping , Optional , Type , Union
+from bumpversion.utils import extract_regex_flags
+
if TYPE_CHECKING : # pragma: no-coverage
from bumpversion.config import Config
@@ -323,7 +329,7 @@ Source code for bumpversion.scm
raise NotImplementedError ()
[docs] @classmethod
-
def latest_tag_info ( cls , tag_pattern : str ) -> SCMInfo :
+
def latest_tag_info ( cls , tag_name : str , parse_pattern : str ) -> SCMInfo :
"""Return information about the latest tag."""
raise NotImplementedError ()
@@ -346,6 +352,16 @@ Source code for bumpversion.scm
except ( FileNotFoundError , PermissionError , NotADirectoryError , subprocess . CalledProcessError ):
return []
+[docs] @classmethod
+
def get_version_from_tag ( cls , tag : str , tag_name : str , parse_pattern : str ) -> Optional [ str ]:
+
"""Return the version from a tag."""
+
version_pattern = parse_pattern . replace ( " \\\\ " , " \\ " )
+
version_pattern , regex_flags = extract_regex_flags ( version_pattern )
+
rep = tag_name . replace ( " {new_version} " , f "(?P<current_version> { version_pattern } )" )
+
rep = f " { regex_flags }{ rep } "
+
tag_regex = re . compile ( rep )
+
return match [ "current_version" ] if ( match := tag_regex . match ( tag )) else None
+
[docs] @classmethod
def commit_to_scm (
cls ,
@@ -410,7 +426,6 @@
Source code for bumpversion.scm
tag_name = config . tag_name . format ( ** context )
tag_message = config . tag_message . format ( ** context )
existing_tags = cls . get_all_tags ()
-
do_tag = not dry_run
if tag_name in existing_tags :
@@ -456,7 +471,7 @@ Source code for bumpversion.scm
raise DirtyWorkingDirectoryError ( f "Git working directory is not clean: \n\n { joined_lines } " )
[docs] @classmethod
-
def latest_tag_info ( cls , tag_pattern : str ) -> SCMInfo :
+
def latest_tag_info ( cls , tag_name : str , parse_pattern : str ) -> SCMInfo :
"""Return information about the latest tag."""
try :
# git-describe doesn't update the git-index, so we do that
@@ -464,7 +479,7 @@
Source code for bumpversion.scm
except subprocess . CalledProcessError as e :
logger . debug ( "Error when running git update-index: %s " , e . stderr )
return SCMInfo ( tool = cls )
-
+ tag_pattern = tag_name . replace ( " {new_version} " , "*" )
try :
# get info about the latest tag in git
git_cmd = [
@@ -497,7 +512,8 @@ Source code for bumpversion.scm
info . commit_sha = describe_out . pop () . lstrip ( "g" )
info . distance_to_latest_tag = int ( describe_out . pop ())
- info . current_version = "-" . join ( describe_out ) . lstrip ( "v" )
+ version = cls . get_version_from_tag ( describe_out [ - 1 ], tag_name , parse_pattern )
+ info . current_version = version or "-" . join ( describe_out ) . lstrip ( "v" )
return info
@@ -535,10 +551,10 @@ Source code for bumpversion.scm
_ALL_TAGS_COMMAND : ClassVar [ List [ str ]] = [ "hg" , "log" , '--rev="tag()"' , '--template=" {tags} \n "' ]
[docs] @classmethod
-
def latest_tag_info ( cls , tag_pattern : str ) -> SCMInfo :
+
def latest_tag_info ( cls , tag_name : str , parse_pattern : str ) -> SCMInfo :
"""Return information about the latest tag."""
current_version = None
-
re_pattern = tag_pattern . replace ( "*" , ".*" )
+
re_pattern = tag_name . replace ( " {new_version} " , ".*" )
result = subprocess . run (
[ "hg" , "log" , "-r" , f "tag('re: { re_pattern } ')" , "--template" , " {latesttag} \n " ], # noqa: S603, S607
text = True ,
@@ -547,7 +563,10 @@
Source code for bumpversion.scm
)
result . check_returncode ()
if result . stdout :
- current_version = result . stdout . splitlines ( keepends = False )[ - 1 ] . lstrip ( "v" )
+ tag_string = result . stdout . splitlines ( keepends = False )[ - 1 ]
+ current_version = cls . get_version_from_tag ( tag_string , tag_name , parse_pattern )
+ else :
+ logger . debug ( "No tags found" )
is_dirty = len ( subprocess . check_output ([ "hg" , "status" , "-mard" ])) != 0 # noqa: S603, S607
return SCMInfo ( tool = cls , current_version = current_version , dirty = is_dirty )
@@ -593,12 +612,12 @@
Source code for bumpversion.scm
subprocess . check_output ( command ) # noqa: S603
-[docs] def get_scm_info ( tag_pattern : str ) -> SCMInfo :
+
[docs] def get_scm_info ( tag_name : str , parse_pattern : str ) -> SCMInfo :
"""Return a dict with the latest source code management info."""
if Git . is_usable ():
-
return Git . latest_tag_info ( tag_pattern )
+
return Git . latest_tag_info ( tag_name , parse_pattern )
elif Mercurial . is_usable ():
-
return Mercurial . latest_tag_info ( tag_pattern )
+
return Mercurial . latest_tag_info ( tag_name , parse_pattern )
else :
return SCMInfo ()
diff --git a/_modules/bumpversion/show.html b/_modules/bumpversion/show.html
index 6345a713..1eda07ad 100644
--- a/_modules/bumpversion/show.html
+++ b/_modules/bumpversion/show.html
@@ -176,27 +176,31 @@
Version parts
Search and replace configuration
bumpversion
Toggle navigation of bumpversion
-
Explanation Toggle navigation of Explanation
+Explanation Toggle navigation of Explanation
Contributing to Bump My Version
@@ -245,7 +249,7 @@ Source code for bumpversion.show
from bumpversion.config import Config
from bumpversion.exceptions import BadInputError
from bumpversion.ui import print_error , print_info
-from bumpversion.utils import get_context
+from bumpversion.utils import get_context , recursive_sort_dict
[docs] def output_default ( value : dict ) -> None :
@@ -254,7 +258,7 @@
Source code for bumpversion.show
print_info ( next ( iter ( value . values ())))
else :
buffer = StringIO ()
- pprint ( value , stream = buffer ) # noqa: T203
+ pprint ( value , stream = buffer , sort_dicts = True ) # noqa: T203
print_info ( buffer . getvalue ())
@@ -262,7 +266,7 @@
Source code for bumpversion.show
"""Output the value as yaml."""
from bumpversion.yaml_dump import dump
- print_info ( dump ( value ))
+
print_info ( dump ( recursive_sort_dict ( value )))
[docs] def output_json ( value : dict ) -> None :
@@ -354,13 +358,14 @@
Source code for bumpversion.show
print_info ( f "new_version= { next_version_str } " )
- for key , value in config . dict ( exclude = { "scm_info" , "parts" }) . items ():
+ config_dict = recursive_sort_dict ( config . model_dump ( exclude = { "scm_info" , "parts" }))
+ for key , value in config_dict . items ():
print_info ( f " { key } = { value } " )
[docs] def do_show ( * args , config : Config , format_ : str = "default" , increment : Optional [ str ] = None ) -> None :
"""Show current version or configuration information."""
-
config_dict = config . dict ()
+
config_dict = config . model_dump ()
ctx = get_context ( config )
if increment :
diff --git a/_modules/bumpversion/ui.html b/_modules/bumpversion/ui.html
index 28ef3550..482c50e9 100644
--- a/_modules/bumpversion/ui.html
+++ b/_modules/bumpversion/ui.html
@@ -176,27 +176,31 @@
Version parts
Search and replace configuration
bumpversion
Toggle navigation of bumpversion
-
Explanation Toggle navigation of Explanation
+Explanation Toggle navigation of Explanation
Contributing to Bump My Version
@@ -236,7 +240,35 @@
Source code for bumpversion.ui
"""Utilities for user interface."""
+import logging
+
+import click
from click import UsageError , secho
+from rich.logging import RichHandler
+
+logger = logging . getLogger ( "bumpversion" )
+
+VERBOSITY = {
+ 0 : logging . WARNING ,
+ 1 : logging . INFO ,
+ 2 : logging . DEBUG ,
+}
+
+
+[docs] def setup_logging ( verbose : int = 0 ) -> None :
+
"""Configure the logging."""
+
logging . basicConfig (
+
level = VERBOSITY . get ( verbose , logging . DEBUG ),
+
format = " %(message)s " ,
+
datefmt = "[ %X ]" ,
+
handlers = [
+
RichHandler (
+
rich_tracebacks = True , show_level = False , show_path = False , show_time = False , tracebacks_suppress = [ click ]
+
)
+
],
+
)
+
root_logger = logging . getLogger ( "" )
+
root_logger . setLevel ( VERBOSITY . get ( verbose , logging . DEBUG ))
[docs] def print_info ( msg : str ) -> None :
diff --git a/_modules/bumpversion/utils.html b/_modules/bumpversion/utils.html
index f5377144..71c94fdc 100644
--- a/_modules/bumpversion/utils.html
+++ b/_modules/bumpversion/utils.html
@@ -176,27 +176,31 @@
Version parts
Search and replace configuration
bumpversion
Toggle navigation of bumpversion
-
Explanation Toggle navigation of Explanation
+Explanation Toggle navigation of Explanation
Contributing to Bump My Version
@@ -239,13 +243,38 @@ Source code for bumpversion.utils
import string
from collections import ChainMap
from dataclasses import asdict
-from typing import TYPE_CHECKING , List , Optional
+from typing import TYPE_CHECKING , Any , List , Optional , Tuple
if TYPE_CHECKING : # pragma: no-coverage
from bumpversion.config import Config
from bumpversion.version_part import Version
+
+
+
+[docs] def recursive_sort_dict ( input_value : Any ) -> Any :
+
"""Sort a dictionary recursively."""
+
if not isinstance ( input_value , dict ):
+
return input_value
+
+
return { key : recursive_sort_dict ( input_value [ key ]) for key in sorted ( input_value . keys ())}
+
+
[docs] def key_val_string ( d : dict ) -> str :
"""Render the dictionary as a comma-delimited key=value string."""
return ", " . join ( f " { k } = { v } " for k , v in sorted ( d . items ()))
diff --git a/_modules/bumpversion/version_part.html b/_modules/bumpversion/version_part.html
index bc3471ef..d50ca6f5 100644
--- a/_modules/bumpversion/version_part.html
+++ b/_modules/bumpversion/version_part.html
@@ -176,27 +176,31 @@
Version parts
Search and replace configuration
bumpversion
Toggle navigation of bumpversion
-
Explanation Toggle navigation of Explanation
+Explanation Toggle navigation of Explanation
Contributing to Bump My Version
@@ -244,7 +248,7 @@ Source code for bumpversion.version_part
from click import UsageError
-from bumpversion.config import VersionPartConfig
+from bumpversion.config.models import VersionPartConfig
from bumpversion.exceptions import FormattingError , InvalidVersionPartError , MissingValueError
from bumpversion.functions import NumericFunction , PartFunction , ValuesFunction
from bumpversion.utils import key_val_string , labels_for_format
@@ -383,6 +387,7 @@ Source code for bumpversion.version_part
self . serialize_formats = serialize
self . part_configs = part_configs or {}
+ # TODO: I think these two should be removed from the config object
self . search = search
self . replace = replace
diff --git a/_modules/bumpversion/yaml_dump.html b/_modules/bumpversion/yaml_dump.html
index f5e17715..431e4a34 100644
--- a/_modules/bumpversion/yaml_dump.html
+++ b/_modules/bumpversion/yaml_dump.html
@@ -176,27 +176,31 @@
Version parts
Search and replace configuration
bumpversion
Toggle navigation of bumpversion
-
Explanation Toggle navigation of Explanation
-
Explanation Toggle navigation of Explanation
+Explanation Toggle navigation of Explanation
Contributing to Bump My Version
@@ -239,10 +243,12 @@ All modules for which code is available
bumpversion.autocast
bumpversion.bump
bumpversion.config
-bumpversion.exceptions
+bumpversion.exceptions
bumpversion.files
bumpversion.functions
-bumpversion.logging
bumpversion.scm
bumpversion.show
bumpversion.ui
diff --git a/_sources/reference/bumpversion/bumpversion.config.files.md.txt b/_sources/reference/bumpversion/bumpversion.config.files.md.txt
new file mode 100644
index 00000000..395d62db
--- /dev/null
+++ b/_sources/reference/bumpversion/bumpversion.config.files.md.txt
@@ -0,0 +1,122 @@
+# {py:mod}`bumpversion.config.files`
+
+```{py:module} bumpversion.config.files
+```
+
+```{autodoc2-docstring} bumpversion.config.files
+:allowtitles:
+```
+
+## Module Contents
+
+### Functions
+
+````{list-table}
+:class: autosummary longtable
+:align: left
+
+* - {py:obj}`find_config_file `
+ - ```{autodoc2-docstring} bumpversion.config.files.find_config_file
+ :summary:
+ ```
+* - {py:obj}`read_config_file `
+ - ```{autodoc2-docstring} bumpversion.config.files.read_config_file
+ :summary:
+ ```
+* - {py:obj}`read_ini_file `
+ - ```{autodoc2-docstring} bumpversion.config.files.read_ini_file
+ :summary:
+ ```
+* - {py:obj}`read_toml_file `
+ - ```{autodoc2-docstring} bumpversion.config.files.read_toml_file
+ :summary:
+ ```
+* - {py:obj}`update_config_file `
+ - ```{autodoc2-docstring} bumpversion.config.files.update_config_file
+ :summary:
+ ```
+* - {py:obj}`update_ini_config_file `
+ - ```{autodoc2-docstring} bumpversion.config.files.update_ini_config_file
+ :summary:
+ ```
+````
+
+### Data
+
+````{list-table}
+:class: autosummary longtable
+:align: left
+
+* - {py:obj}`logger `
+ - ```{autodoc2-docstring} bumpversion.config.files.logger
+ :summary:
+ ```
+* - {py:obj}`CONFIG_FILE_SEARCH_ORDER `
+ - ```{autodoc2-docstring} bumpversion.config.files.CONFIG_FILE_SEARCH_ORDER
+ :summary:
+ ```
+````
+
+### API
+
+````{py:data} logger
+:canonical: bumpversion.config.files.logger
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.files.logger
+```
+
+````
+
+````{py:data} CONFIG_FILE_SEARCH_ORDER
+:canonical: bumpversion.config.files.CONFIG_FILE_SEARCH_ORDER
+:value: >
+ ()
+
+```{autodoc2-docstring} bumpversion.config.files.CONFIG_FILE_SEARCH_ORDER
+```
+
+````
+
+````{py:function} find_config_file(explicit_file: typing.Union[str, pathlib.Path, None] = None) -> typing.Union[pathlib.Path, None]
+:canonical: bumpversion.config.files.find_config_file
+
+```{autodoc2-docstring} bumpversion.config.files.find_config_file
+```
+````
+
+````{py:function} read_config_file(config_file: typing.Union[str, pathlib.Path, None] = None) -> typing.Dict[str, typing.Any]
+:canonical: bumpversion.config.files.read_config_file
+
+```{autodoc2-docstring} bumpversion.config.files.read_config_file
+```
+````
+
+````{py:function} read_ini_file(file_path: pathlib.Path) -> typing.Dict[str, typing.Any]
+:canonical: bumpversion.config.files.read_ini_file
+
+```{autodoc2-docstring} bumpversion.config.files.read_ini_file
+```
+````
+
+````{py:function} read_toml_file(file_path: pathlib.Path) -> typing.Dict[str, typing.Any]
+:canonical: bumpversion.config.files.read_toml_file
+
+```{autodoc2-docstring} bumpversion.config.files.read_toml_file
+```
+````
+
+````{py:function} update_config_file(config_file: typing.Union[str, pathlib.Path], config: bumpversion.config.models.Config, current_version: bumpversion.version_part.Version, new_version: bumpversion.version_part.Version, context: typing.MutableMapping, dry_run: bool = False) -> None
+:canonical: bumpversion.config.files.update_config_file
+
+```{autodoc2-docstring} bumpversion.config.files.update_config_file
+```
+````
+
+````{py:function} update_ini_config_file(config_file: typing.Union[str, pathlib.Path], current_version: str, new_version: str, dry_run: bool = False) -> None
+:canonical: bumpversion.config.files.update_ini_config_file
+
+```{autodoc2-docstring} bumpversion.config.files.update_ini_config_file
+```
+````
diff --git a/_sources/reference/bumpversion/bumpversion.config.md.txt b/_sources/reference/bumpversion/bumpversion.config.md.txt
index d8d3c8a7..d5c2347a 100644
--- a/_sources/reference/bumpversion/bumpversion.config.md.txt
+++ b/_sources/reference/bumpversion/bumpversion.config.md.txt
@@ -7,27 +7,18 @@
:allowtitles:
```
-## Module Contents
+## Submodules
-### Classes
+```{toctree}
+:titlesonly:
+:maxdepth: 1
-````{list-table}
-:class: autosummary longtable
-:align: left
+bumpversion.config.files
+bumpversion.config.models
+bumpversion.config.utils
+```
-* - {py:obj}`VersionPartConfig `
- - ```{autodoc2-docstring} bumpversion.config.VersionPartConfig
- :summary:
- ```
-* - {py:obj}`FileConfig `
- - ```{autodoc2-docstring} bumpversion.config.FileConfig
- :summary:
- ```
-* - {py:obj}`Config `
- - ```{autodoc2-docstring} bumpversion.config.Config
- :summary:
- ```
-````
+## Package Contents
### Functions
@@ -35,46 +26,14 @@
:class: autosummary longtable
:align: left
-* - {py:obj}`get_all_file_configs `
- - ```{autodoc2-docstring} bumpversion.config.get_all_file_configs
- :summary:
- ```
* - {py:obj}`get_configuration `
- ```{autodoc2-docstring} bumpversion.config.get_configuration
:summary:
```
-* - {py:obj}`get_all_part_configs `
- - ```{autodoc2-docstring} bumpversion.config.get_all_part_configs
- :summary:
- ```
* - {py:obj}`check_current_version `
- ```{autodoc2-docstring} bumpversion.config.check_current_version
:summary:
```
-* - {py:obj}`find_config_file `
- - ```{autodoc2-docstring} bumpversion.config.find_config_file
- :summary:
- ```
-* - {py:obj}`read_config_file `
- - ```{autodoc2-docstring} bumpversion.config.read_config_file
- :summary:
- ```
-* - {py:obj}`read_ini_file `
- - ```{autodoc2-docstring} bumpversion.config.read_ini_file
- :summary:
- ```
-* - {py:obj}`read_toml_file `
- - ```{autodoc2-docstring} bumpversion.config.read_toml_file
- :summary:
- ```
-* - {py:obj}`update_config_file `
- - ```{autodoc2-docstring} bumpversion.config.update_config_file
- :summary:
- ```
-* - {py:obj}`get_glob_files `
- - ```{autodoc2-docstring} bumpversion.config.get_glob_files
- :summary:
- ```
````
### Data
@@ -91,10 +50,6 @@
- ```{autodoc2-docstring} bumpversion.config.DEFAULTS
:summary:
```
-* - {py:obj}`CONFIG_FILE_SEARCH_ORDER `
- - ```{autodoc2-docstring} bumpversion.config.CONFIG_FILE_SEARCH_ORDER
- :summary:
- ```
````
### API
@@ -109,451 +64,6 @@
````
-`````{py:class} VersionPartConfig(**data: typing.Any)
-:canonical: bumpversion.config.VersionPartConfig
-
-Bases: {py:obj}`pydantic.BaseModel`
-
-```{autodoc2-docstring} bumpversion.config.VersionPartConfig
-```
-
-```{rubric} Initialization
-```
-
-```{autodoc2-docstring} bumpversion.config.VersionPartConfig.__init__
-```
-
-````{py:attribute} values
-:canonical: bumpversion.config.VersionPartConfig.values
-:type: typing.Optional[list]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.VersionPartConfig.values
-```
-
-````
-
-````{py:attribute} optional_value
-:canonical: bumpversion.config.VersionPartConfig.optional_value
-:type: typing.Optional[str]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.VersionPartConfig.optional_value
-```
-
-````
-
-````{py:attribute} first_value
-:canonical: bumpversion.config.VersionPartConfig.first_value
-:type: typing.Union[str, int, None]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.VersionPartConfig.first_value
-```
-
-````
-
-````{py:attribute} independent
-:canonical: bumpversion.config.VersionPartConfig.independent
-:type: bool
-:value: >
- False
-
-```{autodoc2-docstring} bumpversion.config.VersionPartConfig.independent
-```
-
-````
-
-`````
-
-`````{py:class} FileConfig(**data: typing.Any)
-:canonical: bumpversion.config.FileConfig
-
-Bases: {py:obj}`pydantic.BaseModel`
-
-```{autodoc2-docstring} bumpversion.config.FileConfig
-```
-
-```{rubric} Initialization
-```
-
-```{autodoc2-docstring} bumpversion.config.FileConfig.__init__
-```
-
-````{py:attribute} filename
-:canonical: bumpversion.config.FileConfig.filename
-:type: typing.Optional[str]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.FileConfig.filename
-```
-
-````
-
-````{py:attribute} glob
-:canonical: bumpversion.config.FileConfig.glob
-:type: typing.Optional[str]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.FileConfig.glob
-```
-
-````
-
-````{py:attribute} parse
-:canonical: bumpversion.config.FileConfig.parse
-:type: typing.Optional[str]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.FileConfig.parse
-```
-
-````
-
-````{py:attribute} serialize
-:canonical: bumpversion.config.FileConfig.serialize
-:type: typing.Optional[typing.List[str]]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.FileConfig.serialize
-```
-
-````
-
-````{py:attribute} search
-:canonical: bumpversion.config.FileConfig.search
-:type: typing.Optional[str]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.FileConfig.search
-```
-
-````
-
-````{py:attribute} replace
-:canonical: bumpversion.config.FileConfig.replace
-:type: typing.Optional[str]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.FileConfig.replace
-```
-
-````
-
-````{py:attribute} regex
-:canonical: bumpversion.config.FileConfig.regex
-:type: typing.Optional[bool]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.FileConfig.regex
-```
-
-````
-
-````{py:attribute} ignore_missing_version
-:canonical: bumpversion.config.FileConfig.ignore_missing_version
-:type: typing.Optional[bool]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.FileConfig.ignore_missing_version
-```
-
-````
-
-`````
-
-`````{py:class} Config(_case_sensitive: bool | None = None, _env_prefix: str | None = None, _env_file: pydantic_settings.sources.DotenvType | None = ENV_FILE_SENTINEL, _env_file_encoding: str | None = None, _env_nested_delimiter: str | None = None, _secrets_dir: str | pathlib.Path | None = None, **values: typing.Any)
-:canonical: bumpversion.config.Config
-
-Bases: {py:obj}`pydantic_settings.BaseSettings`
-
-```{autodoc2-docstring} bumpversion.config.Config
-```
-
-```{rubric} Initialization
-```
-
-```{autodoc2-docstring} bumpversion.config.Config.__init__
-```
-
-````{py:attribute} current_version
-:canonical: bumpversion.config.Config.current_version
-:type: typing.Optional[str]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.current_version
-```
-
-````
-
-````{py:attribute} parse
-:canonical: bumpversion.config.Config.parse
-:type: str
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.parse
-```
-
-````
-
-````{py:attribute} serialize
-:canonical: bumpversion.config.Config.serialize
-:type: typing.List[str]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.serialize
-```
-
-````
-
-````{py:attribute} search
-:canonical: bumpversion.config.Config.search
-:type: str
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.search
-```
-
-````
-
-````{py:attribute} replace
-:canonical: bumpversion.config.Config.replace
-:type: str
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.replace
-```
-
-````
-
-````{py:attribute} regex
-:canonical: bumpversion.config.Config.regex
-:type: bool
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.regex
-```
-
-````
-
-````{py:attribute} ignore_missing_version
-:canonical: bumpversion.config.Config.ignore_missing_version
-:type: bool
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.ignore_missing_version
-```
-
-````
-
-````{py:attribute} tag
-:canonical: bumpversion.config.Config.tag
-:type: bool
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.tag
-```
-
-````
-
-````{py:attribute} sign_tags
-:canonical: bumpversion.config.Config.sign_tags
-:type: bool
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.sign_tags
-```
-
-````
-
-````{py:attribute} tag_name
-:canonical: bumpversion.config.Config.tag_name
-:type: str
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.tag_name
-```
-
-````
-
-````{py:attribute} tag_message
-:canonical: bumpversion.config.Config.tag_message
-:type: typing.Optional[str]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.tag_message
-```
-
-````
-
-````{py:attribute} allow_dirty
-:canonical: bumpversion.config.Config.allow_dirty
-:type: bool
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.allow_dirty
-```
-
-````
-
-````{py:attribute} commit
-:canonical: bumpversion.config.Config.commit
-:type: bool
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.commit
-```
-
-````
-
-````{py:attribute} message
-:canonical: bumpversion.config.Config.message
-:type: str
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.message
-```
-
-````
-
-````{py:attribute} commit_args
-:canonical: bumpversion.config.Config.commit_args
-:type: typing.Optional[str]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.commit_args
-```
-
-````
-
-````{py:attribute} scm_info
-:canonical: bumpversion.config.Config.scm_info
-:type: typing.Optional[bumpversion.scm.SCMInfo]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.scm_info
-```
-
-````
-
-````{py:attribute} parts
-:canonical: bumpversion.config.Config.parts
-:type: typing.Dict[str, bumpversion.config.VersionPartConfig]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.parts
-```
-
-````
-
-````{py:attribute} files
-:canonical: bumpversion.config.Config.files
-:type: typing.List[bumpversion.config.FileConfig]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.files
-```
-
-````
-
-````{py:attribute} included_paths
-:canonical: bumpversion.config.Config.included_paths
-:type: typing.List[str]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.included_paths
-```
-
-````
-
-````{py:attribute} excluded_paths
-:canonical: bumpversion.config.Config.excluded_paths
-:type: typing.List[str]
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.excluded_paths
-```
-
-````
-
-````{py:attribute} model_config
-:canonical: bumpversion.config.Config.model_config
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.config.Config.model_config
-```
-
-````
-
-````{py:method} add_files(filename: typing.Union[str, typing.List[str]]) -> None
-:canonical: bumpversion.config.Config.add_files
-
-```{autodoc2-docstring} bumpversion.config.Config.add_files
-```
-
-````
-
-````{py:property} resolved_filemap
-:canonical: bumpversion.config.Config.resolved_filemap
-:type: typing.Dict[str, bumpversion.config.FileConfig]
-
-```{autodoc2-docstring} bumpversion.config.Config.resolved_filemap
-```
-
-````
-
-````{py:property} files_to_modify
-:canonical: bumpversion.config.Config.files_to_modify
-:type: typing.List[bumpversion.config.FileConfig]
-
-```{autodoc2-docstring} bumpversion.config.Config.files_to_modify
-```
-
-````
-
-````{py:property} version_config
-:canonical: bumpversion.config.Config.version_config
-:type: bumpversion.version_part.VersionConfig
-
-```{autodoc2-docstring} bumpversion.config.Config.version_config
-```
-
-````
-
-`````
-
````{py:data} DEFAULTS
:canonical: bumpversion.config.DEFAULTS
:value: >
@@ -564,82 +74,16 @@ Bases: {py:obj}`pydantic_settings.BaseSettings`
````
-````{py:data} CONFIG_FILE_SEARCH_ORDER
-:canonical: bumpversion.config.CONFIG_FILE_SEARCH_ORDER
-:value: >
- ()
-
-```{autodoc2-docstring} bumpversion.config.CONFIG_FILE_SEARCH_ORDER
-```
-
-````
-
-````{py:function} get_all_file_configs(config_dict: dict) -> typing.List[bumpversion.config.FileConfig]
-:canonical: bumpversion.config.get_all_file_configs
-
-```{autodoc2-docstring} bumpversion.config.get_all_file_configs
-```
-````
-
-````{py:function} get_configuration(config_file: typing.Union[str, pathlib.Path, None] = None, **overrides) -> bumpversion.config.Config
+````{py:function} get_configuration(config_file: typing.Union[str, pathlib.Path, None] = None, **overrides) -> bumpversion.config.models.Config
:canonical: bumpversion.config.get_configuration
```{autodoc2-docstring} bumpversion.config.get_configuration
```
````
-````{py:function} get_all_part_configs(config_dict: dict) -> typing.Dict[str, bumpversion.config.VersionPartConfig]
-:canonical: bumpversion.config.get_all_part_configs
-
-```{autodoc2-docstring} bumpversion.config.get_all_part_configs
-```
-````
-
-````{py:function} check_current_version(config: bumpversion.config.Config) -> str
+````{py:function} check_current_version(config: bumpversion.config.models.Config) -> str
:canonical: bumpversion.config.check_current_version
```{autodoc2-docstring} bumpversion.config.check_current_version
```
````
-
-````{py:function} find_config_file(explicit_file: typing.Union[str, pathlib.Path, None] = None) -> typing.Union[pathlib.Path, None]
-:canonical: bumpversion.config.find_config_file
-
-```{autodoc2-docstring} bumpversion.config.find_config_file
-```
-````
-
-````{py:function} read_config_file(config_file: typing.Union[str, pathlib.Path, None] = None) -> typing.Dict[str, typing.Any]
-:canonical: bumpversion.config.read_config_file
-
-```{autodoc2-docstring} bumpversion.config.read_config_file
-```
-````
-
-````{py:function} read_ini_file(file_path: pathlib.Path) -> typing.Dict[str, typing.Any]
-:canonical: bumpversion.config.read_ini_file
-
-```{autodoc2-docstring} bumpversion.config.read_ini_file
-```
-````
-
-````{py:function} read_toml_file(file_path: pathlib.Path) -> typing.Dict[str, typing.Any]
-:canonical: bumpversion.config.read_toml_file
-
-```{autodoc2-docstring} bumpversion.config.read_toml_file
-```
-````
-
-````{py:function} update_config_file(config_file: typing.Union[str, pathlib.Path, None], current_version: str, new_version: str, dry_run: bool = False) -> None
-:canonical: bumpversion.config.update_config_file
-
-```{autodoc2-docstring} bumpversion.config.update_config_file
-```
-````
-
-````{py:function} get_glob_files(file_cfg: bumpversion.config.FileConfig) -> typing.List[bumpversion.config.FileConfig]
-:canonical: bumpversion.config.get_glob_files
-
-```{autodoc2-docstring} bumpversion.config.get_glob_files
-```
-````
diff --git a/_sources/reference/bumpversion/bumpversion.config.models.md.txt b/_sources/reference/bumpversion/bumpversion.config.models.md.txt
new file mode 100644
index 00000000..a3535342
--- /dev/null
+++ b/_sources/reference/bumpversion/bumpversion.config.models.md.txt
@@ -0,0 +1,488 @@
+# {py:mod}`bumpversion.config.models`
+
+```{py:module} bumpversion.config.models
+```
+
+```{autodoc2-docstring} bumpversion.config.models
+:allowtitles:
+```
+
+## Module Contents
+
+### Classes
+
+````{list-table}
+:class: autosummary longtable
+:align: left
+
+* - {py:obj}`VersionPartConfig `
+ - ```{autodoc2-docstring} bumpversion.config.models.VersionPartConfig
+ :summary:
+ ```
+* - {py:obj}`FileConfig `
+ - ```{autodoc2-docstring} bumpversion.config.models.FileConfig
+ :summary:
+ ```
+* - {py:obj}`Config `
+ - ```{autodoc2-docstring} bumpversion.config.models.Config
+ :summary:
+ ```
+````
+
+### API
+
+`````{py:class} VersionPartConfig(**data: typing.Any)
+:canonical: bumpversion.config.models.VersionPartConfig
+
+Bases: {py:obj}`pydantic.BaseModel`
+
+```{autodoc2-docstring} bumpversion.config.models.VersionPartConfig
+```
+
+```{rubric} Initialization
+```
+
+```{autodoc2-docstring} bumpversion.config.models.VersionPartConfig.__init__
+```
+
+````{py:attribute} values
+:canonical: bumpversion.config.models.VersionPartConfig.values
+:type: typing.Optional[list]
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.VersionPartConfig.values
+```
+
+````
+
+````{py:attribute} optional_value
+:canonical: bumpversion.config.models.VersionPartConfig.optional_value
+:type: typing.Optional[str]
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.VersionPartConfig.optional_value
+```
+
+````
+
+````{py:attribute} first_value
+:canonical: bumpversion.config.models.VersionPartConfig.first_value
+:type: typing.Union[str, int, None]
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.VersionPartConfig.first_value
+```
+
+````
+
+````{py:attribute} independent
+:canonical: bumpversion.config.models.VersionPartConfig.independent
+:type: bool
+:value: >
+ False
+
+```{autodoc2-docstring} bumpversion.config.models.VersionPartConfig.independent
+```
+
+````
+
+`````
+
+`````{py:class} FileConfig(**data: typing.Any)
+:canonical: bumpversion.config.models.FileConfig
+
+Bases: {py:obj}`pydantic.BaseModel`
+
+```{autodoc2-docstring} bumpversion.config.models.FileConfig
+```
+
+```{rubric} Initialization
+```
+
+```{autodoc2-docstring} bumpversion.config.models.FileConfig.__init__
+```
+
+````{py:attribute} parse
+:canonical: bumpversion.config.models.FileConfig.parse
+:type: str
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.FileConfig.parse
+```
+
+````
+
+````{py:attribute} serialize
+:canonical: bumpversion.config.models.FileConfig.serialize
+:type: typing.List[str]
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.FileConfig.serialize
+```
+
+````
+
+````{py:attribute} search
+:canonical: bumpversion.config.models.FileConfig.search
+:type: str
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.FileConfig.search
+```
+
+````
+
+````{py:attribute} replace
+:canonical: bumpversion.config.models.FileConfig.replace
+:type: str
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.FileConfig.replace
+```
+
+````
+
+````{py:attribute} regex
+:canonical: bumpversion.config.models.FileConfig.regex
+:type: bool
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.FileConfig.regex
+```
+
+````
+
+````{py:attribute} ignore_missing_version
+:canonical: bumpversion.config.models.FileConfig.ignore_missing_version
+:type: bool
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.FileConfig.ignore_missing_version
+```
+
+````
+
+````{py:attribute} filename
+:canonical: bumpversion.config.models.FileConfig.filename
+:type: typing.Optional[str]
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.FileConfig.filename
+```
+
+````
+
+````{py:attribute} glob
+:canonical: bumpversion.config.models.FileConfig.glob
+:type: typing.Optional[str]
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.FileConfig.glob
+```
+
+````
+
+````{py:attribute} key_path
+:canonical: bumpversion.config.models.FileConfig.key_path
+:type: typing.Optional[str]
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.FileConfig.key_path
+```
+
+````
+
+`````
+
+`````{py:class} Config(_case_sensitive: bool | None = None, _env_prefix: str | None = None, _env_file: pydantic_settings.sources.DotenvType | None = ENV_FILE_SENTINEL, _env_file_encoding: str | None = None, _env_nested_delimiter: str | None = None, _secrets_dir: str | pathlib.Path | None = None, **values: typing.Any)
+:canonical: bumpversion.config.models.Config
+
+Bases: {py:obj}`pydantic_settings.BaseSettings`
+
+```{autodoc2-docstring} bumpversion.config.models.Config
+```
+
+```{rubric} Initialization
+```
+
+```{autodoc2-docstring} bumpversion.config.models.Config.__init__
+```
+
+````{py:attribute} current_version
+:canonical: bumpversion.config.models.Config.current_version
+:type: typing.Optional[str]
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.current_version
+```
+
+````
+
+````{py:attribute} parse
+:canonical: bumpversion.config.models.Config.parse
+:type: str
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.parse
+```
+
+````
+
+````{py:attribute} serialize
+:canonical: bumpversion.config.models.Config.serialize
+:type: typing.List[str]
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.serialize
+```
+
+````
+
+````{py:attribute} search
+:canonical: bumpversion.config.models.Config.search
+:type: str
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.search
+```
+
+````
+
+````{py:attribute} replace
+:canonical: bumpversion.config.models.Config.replace
+:type: str
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.replace
+```
+
+````
+
+````{py:attribute} regex
+:canonical: bumpversion.config.models.Config.regex
+:type: bool
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.regex
+```
+
+````
+
+````{py:attribute} ignore_missing_version
+:canonical: bumpversion.config.models.Config.ignore_missing_version
+:type: bool
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.ignore_missing_version
+```
+
+````
+
+````{py:attribute} tag
+:canonical: bumpversion.config.models.Config.tag
+:type: bool
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.tag
+```
+
+````
+
+````{py:attribute} sign_tags
+:canonical: bumpversion.config.models.Config.sign_tags
+:type: bool
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.sign_tags
+```
+
+````
+
+````{py:attribute} tag_name
+:canonical: bumpversion.config.models.Config.tag_name
+:type: str
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.tag_name
+```
+
+````
+
+````{py:attribute} tag_message
+:canonical: bumpversion.config.models.Config.tag_message
+:type: typing.Optional[str]
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.tag_message
+```
+
+````
+
+````{py:attribute} allow_dirty
+:canonical: bumpversion.config.models.Config.allow_dirty
+:type: bool
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.allow_dirty
+```
+
+````
+
+````{py:attribute} commit
+:canonical: bumpversion.config.models.Config.commit
+:type: bool
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.commit
+```
+
+````
+
+````{py:attribute} message
+:canonical: bumpversion.config.models.Config.message
+:type: str
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.message
+```
+
+````
+
+````{py:attribute} commit_args
+:canonical: bumpversion.config.models.Config.commit_args
+:type: typing.Optional[str]
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.commit_args
+```
+
+````
+
+````{py:attribute} scm_info
+:canonical: bumpversion.config.models.Config.scm_info
+:type: typing.Optional[bumpversion.scm.SCMInfo]
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.scm_info
+```
+
+````
+
+````{py:attribute} parts
+:canonical: bumpversion.config.models.Config.parts
+:type: typing.Dict[str, bumpversion.config.models.VersionPartConfig]
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.parts
+```
+
+````
+
+````{py:attribute} files
+:canonical: bumpversion.config.models.Config.files
+:type: typing.List[bumpversion.config.models.FileConfig]
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.files
+```
+
+````
+
+````{py:attribute} included_paths
+:canonical: bumpversion.config.models.Config.included_paths
+:type: typing.List[str]
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.included_paths
+```
+
+````
+
+````{py:attribute} excluded_paths
+:canonical: bumpversion.config.models.Config.excluded_paths
+:type: typing.List[str]
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.excluded_paths
+```
+
+````
+
+````{py:attribute} model_config
+:canonical: bumpversion.config.models.Config.model_config
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.config.models.Config.model_config
+```
+
+````
+
+````{py:method} add_files(filename: typing.Union[str, typing.List[str]]) -> None
+:canonical: bumpversion.config.models.Config.add_files
+
+```{autodoc2-docstring} bumpversion.config.models.Config.add_files
+```
+
+````
+
+````{py:property} resolved_filemap
+:canonical: bumpversion.config.models.Config.resolved_filemap
+:type: typing.Dict[str, bumpversion.config.models.FileConfig]
+
+```{autodoc2-docstring} bumpversion.config.models.Config.resolved_filemap
+```
+
+````
+
+````{py:property} files_to_modify
+:canonical: bumpversion.config.models.Config.files_to_modify
+:type: typing.List[bumpversion.config.models.FileConfig]
+
+```{autodoc2-docstring} bumpversion.config.models.Config.files_to_modify
+```
+
+````
+
+````{py:property} version_config
+:canonical: bumpversion.config.models.Config.version_config
+:type: bumpversion.version_part.VersionConfig
+
+```{autodoc2-docstring} bumpversion.config.models.Config.version_config
+```
+
+````
+
+`````
diff --git a/_sources/reference/bumpversion/bumpversion.config.utils.md.txt b/_sources/reference/bumpversion/bumpversion.config.utils.md.txt
new file mode 100644
index 00000000..cd6473d4
--- /dev/null
+++ b/_sources/reference/bumpversion/bumpversion.config.utils.md.txt
@@ -0,0 +1,53 @@
+# {py:mod}`bumpversion.config.utils`
+
+```{py:module} bumpversion.config.utils
+```
+
+```{autodoc2-docstring} bumpversion.config.utils
+:allowtitles:
+```
+
+## Module Contents
+
+### Functions
+
+````{list-table}
+:class: autosummary longtable
+:align: left
+
+* - {py:obj}`get_all_file_configs `
+ - ```{autodoc2-docstring} bumpversion.config.utils.get_all_file_configs
+ :summary:
+ ```
+* - {py:obj}`get_all_part_configs `
+ - ```{autodoc2-docstring} bumpversion.config.utils.get_all_part_configs
+ :summary:
+ ```
+* - {py:obj}`resolve_glob_files `
+ - ```{autodoc2-docstring} bumpversion.config.utils.resolve_glob_files
+ :summary:
+ ```
+````
+
+### API
+
+````{py:function} get_all_file_configs(config_dict: dict) -> typing.List[bumpversion.config.models.FileConfig]
+:canonical: bumpversion.config.utils.get_all_file_configs
+
+```{autodoc2-docstring} bumpversion.config.utils.get_all_file_configs
+```
+````
+
+````{py:function} get_all_part_configs(config_dict: dict) -> typing.Dict[str, bumpversion.config.models.VersionPartConfig]
+:canonical: bumpversion.config.utils.get_all_part_configs
+
+```{autodoc2-docstring} bumpversion.config.utils.get_all_part_configs
+```
+````
+
+````{py:function} resolve_glob_files(file_cfg: bumpversion.config.models.FileConfig) -> typing.List[bumpversion.config.models.FileConfig]
+:canonical: bumpversion.config.utils.resolve_glob_files
+
+```{autodoc2-docstring} bumpversion.config.utils.resolve_glob_files
+```
+````
diff --git a/_sources/reference/bumpversion/bumpversion.files.md.txt b/_sources/reference/bumpversion/bumpversion.files.md.txt
index d3ec4eec..023a1590 100644
--- a/_sources/reference/bumpversion/bumpversion.files.md.txt
+++ b/_sources/reference/bumpversion/bumpversion.files.md.txt
@@ -19,6 +19,14 @@
- ```{autodoc2-docstring} bumpversion.files.ConfiguredFile
:summary:
```
+* - {py:obj}`FileUpdater `
+ - ```{autodoc2-docstring} bumpversion.files.FileUpdater
+ :summary:
+ ```
+* - {py:obj}`DataFileUpdater `
+ - ```{autodoc2-docstring} bumpversion.files.DataFileUpdater
+ :summary:
+ ```
````
### Functions
@@ -27,6 +35,18 @@
:class: autosummary longtable
:align: left
+* - {py:obj}`get_search_pattern `
+ - ```{autodoc2-docstring} bumpversion.files.get_search_pattern
+ :summary:
+ ```
+* - {py:obj}`contains_pattern `
+ - ```{autodoc2-docstring} bumpversion.files.contains_pattern
+ :summary:
+ ```
+* - {py:obj}`log_changes `
+ - ```{autodoc2-docstring} bumpversion.files.log_changes
+ :summary:
+ ```
* - {py:obj}`resolve_file_config `
- ```{autodoc2-docstring} bumpversion.files.resolve_file_config
:summary:
@@ -65,7 +85,28 @@
````
-`````{py:class} ConfiguredFile(file_cfg: bumpversion.config.FileConfig, version_config: bumpversion.version_part.VersionConfig, search: typing.Optional[str] = None, replace: typing.Optional[str] = None)
+````{py:function} get_search_pattern(search_str: str, context: typing.MutableMapping, use_regex: bool = False) -> typing.Tuple[re.Pattern, str]
+:canonical: bumpversion.files.get_search_pattern
+
+```{autodoc2-docstring} bumpversion.files.get_search_pattern
+```
+````
+
+````{py:function} contains_pattern(search: re.Pattern, contents: str) -> bool
+:canonical: bumpversion.files.contains_pattern
+
+```{autodoc2-docstring} bumpversion.files.contains_pattern
+```
+````
+
+````{py:function} log_changes(file_path: str, file_content_before: str, file_content_after: str, dry_run: bool = False) -> None
+:canonical: bumpversion.files.log_changes
+
+```{autodoc2-docstring} bumpversion.files.log_changes
+```
+````
+
+`````{py:class} ConfiguredFile(file_cfg: bumpversion.config.models.FileConfig, version_config: bumpversion.version_part.VersionConfig, search: typing.Optional[str] = None, replace: typing.Optional[str] = None)
:canonical: bumpversion.files.ConfiguredFile
```{autodoc2-docstring} bumpversion.files.ConfiguredFile
@@ -101,14 +142,6 @@
````
-````{py:method} contains(search: re.Pattern) -> bool
-:canonical: bumpversion.files.ConfiguredFile.contains
-
-```{autodoc2-docstring} bumpversion.files.ConfiguredFile.contains
-```
-
-````
-
````{py:method} replace_version(current_version: bumpversion.version_part.Version, new_version: bumpversion.version_part.Version, context: typing.MutableMapping, dry_run: bool = False) -> None
:canonical: bumpversion.files.ConfiguredFile.replace_version
@@ -117,14 +150,6 @@
````
-````{py:method} get_search_pattern(context: typing.MutableMapping) -> typing.Tuple[re.Pattern, str]
-:canonical: bumpversion.files.ConfiguredFile.get_search_pattern
-
-```{autodoc2-docstring} bumpversion.files.ConfiguredFile.get_search_pattern
-```
-
-````
-
````{py:method} __str__() -> str
:canonical: bumpversion.files.ConfiguredFile.__str__
@@ -137,7 +162,7 @@
`````
-````{py:function} resolve_file_config(files: typing.List[bumpversion.config.FileConfig], version_config: bumpversion.version_part.VersionConfig, search: typing.Optional[str] = None, replace: typing.Optional[str] = None) -> typing.List[bumpversion.files.ConfiguredFile]
+````{py:function} resolve_file_config(files: typing.List[bumpversion.config.models.FileConfig], version_config: bumpversion.version_part.VersionConfig, search: typing.Optional[str] = None, replace: typing.Optional[str] = None) -> typing.List[bumpversion.files.ConfiguredFile]
:canonical: bumpversion.files.resolve_file_config
```{autodoc2-docstring} bumpversion.files.resolve_file_config
@@ -157,3 +182,55 @@
```{autodoc2-docstring} bumpversion.files._check_files_contain_version
```
````
+
+`````{py:class} FileUpdater(file_cfg: bumpversion.config.models.FileConfig, version_config: bumpversion.version_part.VersionConfig, search: typing.Optional[str] = None, replace: typing.Optional[str] = None)
+:canonical: bumpversion.files.FileUpdater
+
+```{autodoc2-docstring} bumpversion.files.FileUpdater
+```
+
+```{rubric} Initialization
+```
+
+```{autodoc2-docstring} bumpversion.files.FileUpdater.__init__
+```
+
+````{py:method} update_file(current_version: bumpversion.version_part.Version, new_version: bumpversion.version_part.Version, context: typing.MutableMapping, dry_run: bool = False) -> None
+:canonical: bumpversion.files.FileUpdater.update_file
+
+```{autodoc2-docstring} bumpversion.files.FileUpdater.update_file
+```
+
+````
+
+`````
+
+`````{py:class} DataFileUpdater(file_cfg: bumpversion.config.models.FileConfig, version_part_configs: typing.Dict[str, bumpversion.config.models.VersionPartConfig])
+:canonical: bumpversion.files.DataFileUpdater
+
+```{autodoc2-docstring} bumpversion.files.DataFileUpdater
+```
+
+```{rubric} Initialization
+```
+
+```{autodoc2-docstring} bumpversion.files.DataFileUpdater.__init__
+```
+
+````{py:method} update_file(current_version: bumpversion.version_part.Version, new_version: bumpversion.version_part.Version, context: typing.MutableMapping, dry_run: bool = False) -> None
+:canonical: bumpversion.files.DataFileUpdater.update_file
+
+```{autodoc2-docstring} bumpversion.files.DataFileUpdater.update_file
+```
+
+````
+
+````{py:method} _update_toml_file(search_for: re.Pattern, raw_search_pattern: str, replace_with: str, dry_run: bool = False) -> None
+:canonical: bumpversion.files.DataFileUpdater._update_toml_file
+
+```{autodoc2-docstring} bumpversion.files.DataFileUpdater._update_toml_file
+```
+
+````
+
+`````
diff --git a/_sources/reference/bumpversion/bumpversion.logging.md.txt b/_sources/reference/bumpversion/bumpversion.logging.md.txt
deleted file mode 100644
index 1f9646e6..00000000
--- a/_sources/reference/bumpversion/bumpversion.logging.md.txt
+++ /dev/null
@@ -1,67 +0,0 @@
-# {py:mod}`bumpversion.logging`
-
-```{py:module} bumpversion.logging
-```
-
-```{autodoc2-docstring} bumpversion.logging
-:allowtitles:
-```
-
-## Module Contents
-
-### Functions
-
-````{list-table}
-:class: autosummary longtable
-:align: left
-
-* - {py:obj}`setup_logging `
- - ```{autodoc2-docstring} bumpversion.logging.setup_logging
- :summary:
- ```
-````
-
-### Data
-
-````{list-table}
-:class: autosummary longtable
-:align: left
-
-* - {py:obj}`logger `
- - ```{autodoc2-docstring} bumpversion.logging.logger
- :summary:
- ```
-* - {py:obj}`VERBOSITY `
- - ```{autodoc2-docstring} bumpversion.logging.VERBOSITY
- :summary:
- ```
-````
-
-### API
-
-````{py:data} logger
-:canonical: bumpversion.logging.logger
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.logging.logger
-```
-
-````
-
-````{py:data} VERBOSITY
-:canonical: bumpversion.logging.VERBOSITY
-:value: >
- None
-
-```{autodoc2-docstring} bumpversion.logging.VERBOSITY
-```
-
-````
-
-````{py:function} setup_logging(verbose: int = 0) -> None
-:canonical: bumpversion.logging.setup_logging
-
-```{autodoc2-docstring} bumpversion.logging.setup_logging
-```
-````
diff --git a/_sources/reference/bumpversion/bumpversion.md.txt b/_sources/reference/bumpversion/bumpversion.md.txt
index a193c5a6..49329022 100644
--- a/_sources/reference/bumpversion/bumpversion.md.txt
+++ b/_sources/reference/bumpversion/bumpversion.md.txt
@@ -7,6 +7,15 @@
:allowtitles:
```
+## Subpackages
+
+```{toctree}
+:titlesonly:
+:maxdepth: 3
+
+bumpversion.config
+```
+
## Submodules
```{toctree}
@@ -14,21 +23,19 @@
:maxdepth: 1
bumpversion.files
-bumpversion.aliases
-bumpversion.version_part
-bumpversion.logging
-bumpversion.utils
-bumpversion.exceptions
-bumpversion.autocast
+bumpversion.cli
bumpversion.yaml_dump
-bumpversion.functions
+bumpversion.__main__
+bumpversion.exceptions
+bumpversion.show
bumpversion.ui
bumpversion.bump
-bumpversion.config
-bumpversion.cli
-bumpversion.show
-bumpversion.__main__
+bumpversion.autocast
bumpversion.scm
+bumpversion.utils
+bumpversion.version_part
+bumpversion.aliases
+bumpversion.functions
```
## Package Contents
diff --git a/_sources/reference/bumpversion/bumpversion.scm.md.txt b/_sources/reference/bumpversion/bumpversion.scm.md.txt
index 9d8d0492..d725970e 100644
--- a/_sources/reference/bumpversion/bumpversion.scm.md.txt
+++ b/_sources/reference/bumpversion/bumpversion.scm.md.txt
@@ -231,7 +231,7 @@
````
-````{py:method} latest_tag_info(tag_pattern: str) -> bumpversion.scm.SCMInfo
+````{py:method} latest_tag_info(tag_name: str, parse_pattern: str) -> bumpversion.scm.SCMInfo
:canonical: bumpversion.scm.SourceCodeManager.latest_tag_info
:abstractmethod:
:classmethod:
@@ -270,6 +270,15 @@
````
+````{py:method} get_version_from_tag(tag: str, tag_name: str, parse_pattern: str) -> typing.Optional[str]
+:canonical: bumpversion.scm.SourceCodeManager.get_version_from_tag
+:classmethod:
+
+```{autodoc2-docstring} bumpversion.scm.SourceCodeManager.get_version_from_tag
+```
+
+````
+
````{py:method} commit_to_scm(files: typing.List[typing.Union[str, pathlib.Path]], config: bumpversion.config.Config, context: typing.MutableMapping, extra_args: typing.Optional[typing.List[str]] = None, dry_run: bool = False) -> None
:canonical: bumpversion.scm.SourceCodeManager.commit_to_scm
:classmethod:
@@ -350,7 +359,7 @@ Bases: {py:obj}`bumpversion.scm.SourceCodeManager`
````
-````{py:method} latest_tag_info(tag_pattern: str) -> bumpversion.scm.SCMInfo
+````{py:method} latest_tag_info(tag_name: str, parse_pattern: str) -> bumpversion.scm.SCMInfo
:canonical: bumpversion.scm.Git.latest_tag_info
:classmethod:
@@ -420,7 +429,7 @@ Bases: {py:obj}`bumpversion.scm.SourceCodeManager`
````
-````{py:method} latest_tag_info(tag_pattern: str) -> bumpversion.scm.SCMInfo
+````{py:method} latest_tag_info(tag_name: str, parse_pattern: str) -> bumpversion.scm.SCMInfo
:canonical: bumpversion.scm.Mercurial.latest_tag_info
:classmethod:
@@ -458,7 +467,7 @@ Bases: {py:obj}`bumpversion.scm.SourceCodeManager`
`````
-````{py:function} get_scm_info(tag_pattern: str) -> bumpversion.scm.SCMInfo
+````{py:function} get_scm_info(tag_name: str, parse_pattern: str) -> bumpversion.scm.SCMInfo
:canonical: bumpversion.scm.get_scm_info
```{autodoc2-docstring} bumpversion.scm.get_scm_info
diff --git a/_sources/reference/bumpversion/bumpversion.ui.md.txt b/_sources/reference/bumpversion/bumpversion.ui.md.txt
index 7a57880d..9de1e681 100644
--- a/_sources/reference/bumpversion/bumpversion.ui.md.txt
+++ b/_sources/reference/bumpversion/bumpversion.ui.md.txt
@@ -15,6 +15,10 @@
:class: autosummary longtable
:align: left
+* - {py:obj}`setup_logging `
+ - ```{autodoc2-docstring} bumpversion.ui.setup_logging
+ :summary:
+ ```
* - {py:obj}`print_info `
- ```{autodoc2-docstring} bumpversion.ui.print_info
:summary:
@@ -29,8 +33,51 @@
```
````
+### Data
+
+````{list-table}
+:class: autosummary longtable
+:align: left
+
+* - {py:obj}`logger `
+ - ```{autodoc2-docstring} bumpversion.ui.logger
+ :summary:
+ ```
+* - {py:obj}`VERBOSITY `
+ - ```{autodoc2-docstring} bumpversion.ui.VERBOSITY
+ :summary:
+ ```
+````
+
### API
+````{py:data} logger
+:canonical: bumpversion.ui.logger
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.ui.logger
+```
+
+````
+
+````{py:data} VERBOSITY
+:canonical: bumpversion.ui.VERBOSITY
+:value: >
+ None
+
+```{autodoc2-docstring} bumpversion.ui.VERBOSITY
+```
+
+````
+
+````{py:function} setup_logging(verbose: int = 0) -> None
+:canonical: bumpversion.ui.setup_logging
+
+```{autodoc2-docstring} bumpversion.ui.setup_logging
+```
+````
+
````{py:function} print_info(msg: str) -> None
:canonical: bumpversion.ui.print_info
diff --git a/_sources/reference/bumpversion/bumpversion.utils.md.txt b/_sources/reference/bumpversion/bumpversion.utils.md.txt
index 947afaa7..8d5bfda3 100644
--- a/_sources/reference/bumpversion/bumpversion.utils.md.txt
+++ b/_sources/reference/bumpversion/bumpversion.utils.md.txt
@@ -15,6 +15,14 @@
:class: autosummary longtable
:align: left
+* - {py:obj}`extract_regex_flags `
+ - ```{autodoc2-docstring} bumpversion.utils.extract_regex_flags
+ :summary:
+ ```
+* - {py:obj}`recursive_sort_dict `
+ - ```{autodoc2-docstring} bumpversion.utils.recursive_sort_dict
+ :summary:
+ ```
* - {py:obj}`key_val_string `
- ```{autodoc2-docstring} bumpversion.utils.key_val_string
:summary:
@@ -39,6 +47,20 @@
### API
+````{py:function} extract_regex_flags(regex_pattern: str) -> typing.Tuple[str, str]
+:canonical: bumpversion.utils.extract_regex_flags
+
+```{autodoc2-docstring} bumpversion.utils.extract_regex_flags
+```
+````
+
+````{py:function} recursive_sort_dict(input_value: typing.Any) -> typing.Any
+:canonical: bumpversion.utils.recursive_sort_dict
+
+```{autodoc2-docstring} bumpversion.utils.recursive_sort_dict
+```
+````
+
````{py:function} key_val_string(d: dict) -> str
:canonical: bumpversion.utils.key_val_string
diff --git a/_sources/reference/bumpversion/bumpversion.version_part.md.txt b/_sources/reference/bumpversion/bumpversion.version_part.md.txt
index 47b84273..1891561e 100644
--- a/_sources/reference/bumpversion/bumpversion.version_part.md.txt
+++ b/_sources/reference/bumpversion/bumpversion.version_part.md.txt
@@ -53,7 +53,7 @@
````
-`````{py:class} VersionPart(config: bumpversion.config.VersionPartConfig, value: typing.Union[str, int, None] = None)
+`````{py:class} VersionPart(config: bumpversion.config.models.VersionPartConfig, value: typing.Union[str, int, None] = None)
:canonical: bumpversion.version_part.VersionPart
```{autodoc2-docstring} bumpversion.version_part.VersionPart
@@ -189,7 +189,7 @@
`````
-`````{py:class} VersionConfig(parse: str, serialize: typing.List[str], search: str, replace: str, part_configs: typing.Optional[typing.Dict[str, bumpversion.config.VersionPartConfig]] = None)
+`````{py:class} VersionConfig(parse: str, serialize: typing.List[str], search: str, replace: str, part_configs: typing.Optional[typing.Dict[str, bumpversion.config.models.VersionPartConfig]] = None)
:canonical: bumpversion.version_part.VersionConfig
```{autodoc2-docstring} bumpversion.version_part.VersionConfig
diff --git a/changelog.html b/changelog.html
index af35fa8c..0e7d00bf 100644
--- a/changelog.html
+++ b/changelog.html
@@ -177,27 +177,31 @@
Version parts
Search and replace configuration
bumpversion
Toggle navigation of bumpversion
-
Explanation Toggle navigation of Explanation
-
Explanation Toggle navigation of Explanation
-
Explanation Toggle navigation of Explanation
-
Explanation Toggle navigation of Explanation
+
_update_toml_file() (bumpversion.files.DataFileUpdater method)
+
@@ -604,7 +610,7 @@
A
AliasedGroup (class in bumpversion.aliases)
- allow_dirty (bumpversion.config.Config attribute)
+ allow_dirty (bumpversion.config.models.Config attribute)
- Config (class in bumpversion.config)
+ Config (class in bumpversion.config.models)
- CONFIG_FILE_SEARCH_ORDER (in module bumpversion.config)
+ CONFIG_FILE_SEARCH_ORDER (in module bumpversion.config.files)
ConfigurationError
ConfiguredFile (class in bumpversion.files)
- contains() (bumpversion.files.ConfiguredFile method)
+ contains_pattern() (in module bumpversion.files)
contains_version() (bumpversion.files.ConfiguredFile method)
copy() (bumpversion.version_part.VersionPart method)
- current_version (bumpversion.config.Config attribute)
+ current_version (bumpversion.config.models.Config attribute)
(bumpversion.scm.SCMInfo attribute)
@@ -974,16 +994,18 @@ C
D
+ distance_to_latest_tag (bumpversion.scm.SCMInfo attribute)
+
do_bump() (in module bumpversion.bump)
do_show() (in module bumpversion.show)
@@ -1000,7 +1022,11 @@ D
E
@@ -1010,9 +1036,9 @@ E
F
- files (bumpversion.config.Config attribute)
+ files (bumpversion.config.models.Config attribute)
+
+ files_to_modify (bumpversion.config.models.Config property)
- files_to_modify (bumpversion.config.Config property)
+ FileUpdater (class in bumpversion.files)
- find_config_file() (in module bumpversion.config)
+ find_config_file() (in module bumpversion.config.files)
FIRST_NUMERIC (bumpversion.functions.NumericFunction attribute)
- first_value (bumpversion.config.VersionPartConfig attribute)
+ first_value (bumpversion.config.models.VersionPartConfig attribute)
(bumpversion.functions.PartFunction attribute)
@@ -1065,9 +1093,9 @@ F
G
@@ -1103,17 +1131,17 @@ G
I
- ignore_missing_version (bumpversion.config.Config attribute)
+ ignore_missing_version (bumpversion.config.models.Config attribute)
- included_paths (bumpversion.config.Config attribute)
+ included_paths (bumpversion.config.models.Config attribute)
INDENT (in module bumpversion.yaml_dump)
- independent (bumpversion.config.VersionPartConfig attribute)
+ independent (bumpversion.config.models.VersionPartConfig attribute)
(bumpversion.functions.PartFunction attribute)
@@ -1136,6 +1164,10 @@ I
K
+
listify() (in module bumpversion.autocast)
+
+ log_changes() (in module bumpversion.files)
log_list() (in module bumpversion.show)
@@ -1170,11 +1204,13 @@ L
(in module bumpversion.config)
- (in module bumpversion.files)
+ (in module bumpversion.config.files)
- (in module bumpversion.logging)
+ (in module bumpversion.files)
(in module bumpversion.scm)
+
+ (in module bumpversion.ui)
(in module bumpversion.version_part)
@@ -1189,11 +1225,11 @@ M
Mercurial (class in bumpversion.scm)
- message (bumpversion.config.Config attribute)
+ message (bumpversion.config.models.Config attribute)
MissingValueError
- model_config (bumpversion.config.Config attribute)
+ model_config (bumpversion.config.models.Config attribute)
modify_files() (in module bumpversion.files)
@@ -1214,14 +1250,18 @@ M
bumpversion.cli
bumpversion.config
+
+ bumpversion.config.files
+
+ bumpversion.config.models
+
+ bumpversion.config.utils
bumpversion.exceptions
bumpversion.files
bumpversion.functions
-
- bumpversion.logging
bumpversion.scm
@@ -1260,7 +1300,7 @@ N
O
- optional_value (bumpversion.config.VersionPartConfig attribute)
+ optional_value (bumpversion.config.models.VersionPartConfig attribute)
(bumpversion.functions.PartFunction attribute)
@@ -1286,10 +1326,10 @@ O
P
- parts (bumpversion.config.Config attribute)
+ parts (bumpversion.config.models.Config attribute)
prefixed_environ() (in module bumpversion.utils)
@@ -1316,22 +1356,24 @@ P
R
@@ -1356,33 +1400,33 @@ R
S
@@ -324,288 +293,15 @@ API
None
-
-
-class bumpversion.config. VersionPartConfig ( ** data : Any ) [source]
-Bases: pydantic.BaseModel
-Configuration of a part of the version.
-Initialization
-Create a new model by parsing and validating input data from keyword arguments.
-Raises [ValidationError
][pydantic_core.ValidationError] if the input data cannot be
-validated to form a valid model.
-__init__
uses __pydantic_self__
instead of the more common self
for the first arg to
-allow self
as a field name.
-
-
-values : Optional [ list ]
-None
-
-
-
-
-optional_value : Optional [ str ]
-None
-
-
-
-
-first_value : Union [ str , int , None ]
-None
-
-
-
-
-independent : bool
-False
-
-
-
-
-
-
-class bumpversion.config. FileConfig ( ** data : Any ) [source]
-Bases: pydantic.BaseModel
-Search and replace file config.
-Initialization
-Create a new model by parsing and validating input data from keyword arguments.
-Raises [ValidationError
][pydantic_core.ValidationError] if the input data cannot be
-validated to form a valid model.
-__init__
uses __pydantic_self__
instead of the more common self
for the first arg to
-allow self
as a field name.
-
-
-filename : Optional [ str ]
-None
-
-
-
-
-glob : Optional [ str ]
-None
-
-
-
-
-parse : Optional [ str ]
-None
-
-
-
-
-serialize : Optional [ List [ str ] ]
-None
-
-
-
-
-search : Optional [ str ]
-None
-
-
-
-
-replace : Optional [ str ]
-None
-
-
-
-
-regex : Optional [ bool ]
-None
-
-
-
-
-ignore_missing_version : Optional [ bool ]
-None
-
-
-
-
-
-
-class bumpversion.config. Config ( _case_sensitive : bool | None = None , _env_prefix : str | None = None , _env_file : pydantic_settings.sources.DotenvType | None = ENV_FILE_SENTINEL , _env_file_encoding : str | None = None , _env_nested_delimiter : str | None = None , _secrets_dir : str | pathlib.Path | None = None , ** values : Any ) [source]
-Bases: pydantic_settings.BaseSettings
-Bump Version configuration.
-Initialization
-Create a new model by parsing and validating input data from keyword arguments.
-Raises [ValidationError
][pydantic_core.ValidationError] if the input data cannot be
-validated to form a valid model.
-__init__
uses __pydantic_self__
instead of the more common self
for the first arg to
-allow self
as a field name.
-
-
-current_version : Optional [ str ]
-None
-
-
-
-
-parse : str
-None
-
-
-
-
-serialize : List [ str ]
-None
-
-
-
-
-search : str
-None
-
-
-
-
-replace : str
-None
-
-
-
-
-regex : bool
-None
-
-
-
-
-ignore_missing_version : bool
-None
-
-
-
-
-tag : bool
-None
-
-
-
-
-sign_tags : bool
-None
-
-
-
-
-tag_name : str
-None
-
-
-
-
-tag_message : Optional [ str ]
-None
-
-
-
-
-allow_dirty : bool
-None
-
-
-
-
-commit : bool
-None
-
-
-
-
-message : str
-None
-
-
-
-
-commit_args : Optional [ str ]
-None
-
-
-
-
-scm_info : Optional [ bumpversion.scm.SCMInfo ]
-None
-
-
-
-
-parts : Dict [ str , bumpversion.config.VersionPartConfig ]
-None
-
-
-
-
-files : List [ bumpversion.config.FileConfig ]
-None
-
-
-
-
-included_paths : List [ str ]
-None
-
-
-
-
-excluded_paths : List [ str ]
-None
-
-
-
-
-model_config
-None
-
-
-
-
-add_files ( filename : Union [ str , List [ str ] ] ) → None [source]
-Add a filename to the list of files.
-
-
-
-
-property resolved_filemap : Dict [ str , bumpversion.config.FileConfig ]
-Return a map of filenames to file configs, expanding any globs.
-
-
-
-
-property files_to_modify : List [ bumpversion.config.FileConfig ]
-Return a list of files to modify.
-
-
-
-
-property version_config : bumpversion.version_part.VersionConfig
-Return the version configuration.
-
-
-
-
bumpversion.config. DEFAULTS
None
-
-
-bumpversion.config. CONFIG_FILE_SEARCH_ORDER
-()
-
-
-
-
-bumpversion.config. get_all_file_configs ( config_dict : dict ) → List [ bumpversion.config.FileConfig ] [source]
-Make sure all version parts are included.
-
-
-bumpversion.config. get_configuration ( config_file : Union [ str , pathlib.Path , None ] = None , ** overrides ) → bumpversion.config.Config [source]
+bumpversion.config. get_configuration ( config_file : Union [ str , pathlib.Path , None ] = None , ** overrides ) → bumpversion.config.models.Config [source]
Return the configuration based on any configuration files and overrides.
Args:
config_file: An explicit configuration file to use, otherwise search for one
@@ -614,15 +310,9 @@
API
The configuration
-
-
-bumpversion.config. get_all_part_configs ( config_dict : dict ) → Dict [ str , bumpversion.config.VersionPartConfig ] [source]
-Make sure all version parts are included.
-
-
-bumpversion.config. check_current_version ( config : bumpversion.config.Config ) → str [source]
+bumpversion.config. check_current_version ( config : bumpversion.config.models.Config ) → str [source]
Returns the current version.
If the current version is not specified in the config file, command line or env variable,
it attempts to retrieve it via a tag.
@@ -634,76 +324,6 @@ API
ConfigurationError: If it can’t find the current version
-
-
-bumpversion.config. find_config_file ( explicit_file : Union [ str , pathlib.Path , None ] = None ) → Union [ pathlib.Path , None ] [source]
-Find the configuration file, if it exists.
-If no explicit configuration file is passed, it will search in several files to
-find its configuration.
-Args:
-explicit_file: The configuration file to explicitly use.
-Returns:
-The configuration file path
-
-
-
-
-bumpversion.config. read_config_file ( config_file : Union [ str , pathlib.Path , None ] = None ) → Dict [ str , Any ] [source]
-Read the configuration file, if it exists.
-If no explicit configuration file is passed, it will search in several files to
-find its configuration.
-Args:
-config_file: The configuration file to explicitly use.
-Returns:
-A dictionary of read key-values
-
-
-
-
-bumpversion.config. read_ini_file ( file_path : pathlib.Path ) → Dict [ str , Any ] [source]
-Parse an INI file and return a dictionary of sections and their options.
-Args:
-file_path: The path to the INI file.
-Returns:
-dict: A dictionary of sections and their options.
-
-
-
-
-bumpversion.config. read_toml_file ( file_path : pathlib.Path ) → Dict [ str , Any ] [source]
-Parse a TOML file and return the bumpversion
section.
-Args:
-file_path: The path to the TOML file.
-Returns:
-dict: A dictionary of the bumpversion
section.
-
-
-
-
-bumpversion.config. update_config_file ( config_file : Union [ str , pathlib.Path , None ] , current_version : str , new_version : str , dry_run : bool = False ) → None [source]
-Update the current_version key in the configuration file.
-If no explicit configuration file is passed, it will search in several files to
-find its configuration.
-Instead of parsing and re-writing the config file with new information, it will use
-a regular expression to just replace the current_version value. The idea is it will
-avoid unintentional changes (like formatting) to the config file.
-Args:
-config_file: The configuration file to explicitly use.
-current_version: The serialized current version.
-new_version: The serialized new version.
-dry_run: True if the update should be a dry run.
-
-
-
-
-bumpversion.config. get_glob_files ( file_cfg : bumpversion.config.FileConfig ) → List [ bumpversion.config.FileConfig ] [source]
-Return a list of files that match the glob pattern.
-Args:
-file_cfg: The file configuration containing the glob pattern
-Returns:
-A list of resolved file configurations according to the pattern.
-
-
@@ -713,23 +333,23 @@ API
-
+
Next
-
bumpversion.cli
+
bumpversion.config.files
-
+
Previous
-
bumpversion.bump
+
bumpversion
@@ -771,70 +391,15 @@
API
bumpversion.config
-Module Contents
-Classes
+Submodules
+Package Contents
diff --git a/reference/bumpversion/bumpversion.config.models.html b/reference/bumpversion/bumpversion.config.models.html
new file mode 100644
index 00000000..2daa6ac1
--- /dev/null
+++ b/reference/bumpversion/bumpversion.config.models.html
@@ -0,0 +1,674 @@
+
+
+
+
+
+
+
+
+ bumpversion.config.models - Bump My Version 0.12.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Contents
+
+
+
+
+
+
+ Expand
+
+
+
+
+
+ Light mode
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Dark mode
+
+
+
+
+
+
+ Auto light/dark mode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Hide table of contents sidebar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Back to top
+
+
+
+
+
+ Toggle Light / Dark / Auto color theme
+
+
+
+
+
+
+ Toggle table of contents sidebar
+
+
+
+
+
+bumpversion.config.models
+Bump My Version configuration models.
+
+Module Contents
+
+
+API
+
+
+class bumpversion.config.models. VersionPartConfig ( ** data : Any ) [source]
+Bases: pydantic.BaseModel
+Configuration of a part of the version.
+Initialization
+Create a new model by parsing and validating input data from keyword arguments.
+Raises [ValidationError
][pydantic_core.ValidationError] if the input data cannot be
+validated to form a valid model.
+__init__
uses __pydantic_self__
instead of the more common self
for the first arg to
+allow self
as a field name.
+
+
+values : Optional [ list ]
+None
+
+
+
+
+optional_value : Optional [ str ]
+None
+
+
+
+
+first_value : Union [ str , int , None ]
+None
+
+
+
+
+independent : bool
+False
+
+
+
+
+
+
+class bumpversion.config.models. FileConfig ( ** data : Any ) [source]
+Bases: pydantic.BaseModel
+Search and replace file config.
+Initialization
+Create a new model by parsing and validating input data from keyword arguments.
+Raises [ValidationError
][pydantic_core.ValidationError] if the input data cannot be
+validated to form a valid model.
+__init__
uses __pydantic_self__
instead of the more common self
for the first arg to
+allow self
as a field name.
+
+
+parse : str
+None
+
+
+
+
+serialize : List [ str ]
+None
+
+
+
+
+search : str
+None
+
+
+
+
+replace : str
+None
+
+
+
+
+regex : bool
+None
+
+
+
+
+ignore_missing_version : bool
+None
+
+
+
+
+filename : Optional [ str ]
+None
+
+
+
+
+glob : Optional [ str ]
+None
+
+
+
+
+key_path : Optional [ str ]
+None
+
+
+
+
+
+
+class bumpversion.config.models. Config ( _case_sensitive : bool | None = None , _env_prefix : str | None = None , _env_file : pydantic_settings.sources.DotenvType | None = ENV_FILE_SENTINEL , _env_file_encoding : str | None = None , _env_nested_delimiter : str | None = None , _secrets_dir : str | pathlib.Path | None = None , ** values : Any ) [source]
+Bases: pydantic_settings.BaseSettings
+Bump Version configuration.
+Initialization
+Create a new model by parsing and validating input data from keyword arguments.
+Raises [ValidationError
][pydantic_core.ValidationError] if the input data cannot be
+validated to form a valid model.
+__init__
uses __pydantic_self__
instead of the more common self
for the first arg to
+allow self
as a field name.
+
+
+current_version : Optional [ str ]
+None
+
+
+
+
+parse : str
+None
+
+
+
+
+serialize : List [ str ]
+None
+
+
+
+
+search : str
+None
+
+
+
+
+replace : str
+None
+
+
+
+
+regex : bool
+None
+
+
+
+
+ignore_missing_version : bool
+None
+
+
+
+
+tag : bool
+None
+
+
+
+
+sign_tags : bool
+None
+
+
+
+
+tag_name : str
+None
+
+
+
+
+tag_message : Optional [ str ]
+None
+
+
+
+
+allow_dirty : bool
+None
+
+
+
+
+commit : bool
+None
+
+
+
+
+message : str
+None
+
+
+
+
+commit_args : Optional [ str ]
+None
+
+
+
+
+scm_info : Optional [ bumpversion.scm.SCMInfo ]
+None
+
+
+
+
+parts : Dict [ str , bumpversion.config.models.VersionPartConfig ]
+None
+
+
+
+
+files : List [ bumpversion.config.models.FileConfig ]
+None
+
+
+
+
+included_paths : List [ str ]
+None
+
+
+
+
+excluded_paths : List [ str ]
+None
+
+
+
+
+model_config
+None
+
+
+
+
+add_files ( filename : Union [ str , List [ str ] ] ) → None [source]
+Add a filename to the list of files.
+
+
+
+
+property resolved_filemap : Dict [ str , bumpversion.config.models.FileConfig ]
+Return a map of filenames to file configs, expanding any globs.
+
+
+
+
+property files_to_modify : List [ bumpversion.config.models.FileConfig ]
+Return a list of files to modify.
+
+
+
+
+property version_config : bumpversion.version_part.VersionConfig
+Return the version configuration.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/reference/bumpversion/bumpversion.logging.html b/reference/bumpversion/bumpversion.config.utils.html
similarity index 68%
rename from reference/bumpversion/bumpversion.logging.html
rename to reference/bumpversion/bumpversion.config.utils.html
index 388dd3b9..1b1d2c48 100644
--- a/reference/bumpversion/bumpversion.logging.html
+++ b/reference/bumpversion/bumpversion.config.utils.html
@@ -3,10 +3,10 @@
-
+
- bumpversion.logging - Bump My Version 0.12.0
+ bumpversion.config.utils - Bump My Version 0.12.0
@@ -177,27 +177,31 @@
Version parts
Search and replace configuration
bumpversion
Toggle navigation of bumpversion
-Explanation Toggle navigation of Explanation
-
-
-
-Data
-
-
@@ -270,22 +265,26 @@
Data
+FileUpdater
+A class to handle updating files.
+
+DataFileUpdater
+A class to handle updating files.
+
@@ -258,13 +268,22 @@ Functions
-resolve_file_config
+get_search_pattern
+Render the search pattern and return the compiled regex pattern and the raw pattern.
+
+contains_pattern
+Does the search pattern match any part of the contents?
+
+log_changes
+Log the changes that would be made to the file.
+
+resolve_file_config
Resolve the files, searching and replacing values according to the FileConfig.
-modify_files
+modify_files
Modify the files, searching and replacing values according to the FileConfig.
-_check_files_contain_version
+_check_files_contain_version
Make sure files exist and contain version string.
@@ -291,9 +310,38 @@ API
None
+
+
+bumpversion.files. get_search_pattern ( search_str : str , context : MutableMapping , use_regex : bool = False ) → Tuple [ re.Pattern , str ] [source]
+Render the search pattern and return the compiled regex pattern and the raw pattern.
+Args:
+search_str: A string containing the search pattern as a format string
+context: The context to use for rendering the search pattern
+use_regex: If True, the search pattern is treated as a regex pattern
+Returns:
+A tuple of the compiled regex pattern and the raw pattern as a string.
+
+
+
+
+bumpversion.files. contains_pattern ( search : re.Pattern , contents : str ) → bool [source]
+Does the search pattern match any part of the contents?
+
+
+
+
+bumpversion.files. log_changes ( file_path : str , file_content_before : str , file_content_after : str , dry_run : bool = False ) → None [source]
+Log the changes that would be made to the file.
+Args:
+file_path: The path to the file
+file_content_before: The file contents before the change
+file_content_after: The file contents after the change
+dry_run: True if this is a report-only job
+
+
-class bumpversion.files. ConfiguredFile ( file_cfg : bumpversion.config.FileConfig , version_config : bumpversion.version_part.VersionConfig , search : Optional [ str ] = None , replace : Optional [ str ] = None ) [source]
+class bumpversion.files. ConfiguredFile ( file_cfg : bumpversion.config.models.FileConfig , version_config : bumpversion.version_part.VersionConfig , search : Optional [ str ] = None , replace : Optional [ str ] = None ) [source]
A file to modify in a configured way.
Initialization
@@ -321,24 +369,12 @@ API
True if the version number is in fact present.
-
-
-contains ( search : re.Pattern ) → bool [source]
-Does the work of the contains_version method.
-
-
replace_version ( current_version : bumpversion.version_part.Version , new_version : bumpversion.version_part.Version , context : MutableMapping , dry_run : bool = False ) → None [source]
Replace the current version with the new version.
-
-
-get_search_pattern ( context : MutableMapping ) → Tuple [ re.Pattern , str ] [source]
-Compile and return the regex if it is valid, otherwise return the string.
-
-
__str__ ( ) → str [source]
@@ -353,7 +389,7 @@ API
-bumpversion.files. resolve_file_config ( files : List [ bumpversion.config.FileConfig ] , version_config : bumpversion.version_part.VersionConfig , search : Optional [ str ] = None , replace : Optional [ str ] = None ) → List [ bumpversion.files.ConfiguredFile ] [source]
+bumpversion.files. resolve_file_config ( files : List [ bumpversion.config.models.FileConfig ] , version_config : bumpversion.version_part.VersionConfig , search : Optional [ str ] = None , replace : Optional [ str ] = None ) → List [ bumpversion.files.ConfiguredFile ] [source]
Resolve the files, searching and replacing values according to the FileConfig.
Args:
files: A list of file configurations
@@ -382,6 +418,38 @@
API
Make sure files exist and contain version string.
+
+
+class bumpversion.files. FileUpdater ( file_cfg : bumpversion.config.models.FileConfig , version_config : bumpversion.version_part.VersionConfig , search : Optional [ str ] = None , replace : Optional [ str ] = None ) [source]
+A class to handle updating files.
+Initialization
+
+
+update_file ( current_version : bumpversion.version_part.Version , new_version : bumpversion.version_part.Version , context : MutableMapping , dry_run : bool = False ) → None [source]
+Update the files.
+
+
+
+
+
+
+class bumpversion.files. DataFileUpdater ( file_cfg : bumpversion.config.models.FileConfig , version_part_configs : Dict [ str , bumpversion.config.models.VersionPartConfig ] ) [source]
+A class to handle updating files.
+Initialization
+
+
+update_file ( current_version : bumpversion.version_part.Version , new_version : bumpversion.version_part.Version , context : MutableMapping , dry_run : bool = False ) → None [source]
+Update the files.
+
+
+
+
+_update_toml_file ( search_for : re.Pattern , raw_search_pattern : str , replace_with : str , dry_run : bool = False ) → None [source]
+Update a TOML file.
+
+
+
+
@@ -391,23 +459,23 @@ API