Open SethMMorton opened 6 years ago
Does the str.format
style of using '{named}{fields}'.format(named=one,fields=many)
work instead of the %
formatting?
@espoelstra It is already using str.format
. Sending a datetime object through str.format
requires the old-style %
formatting within the format string - see https://stackoverflow.com/a/22842734/1399279.
So, in my above example, something like the following is what is happening in the code
new_string = '{now:%m-%d-%Y} v. {new_version}'.format(now=datetime.datetime.now(), new_version=new_version_string)
First, thanks for the great tool!
The interpolation behavior of config files by
bumpversion
andsetuptools
is not the same.bumpversion
uses no interpolation (e.g.configparser.RawConfigParser
), butsetuptools
uses the default interpolation ofconfigparser.ConfigParser
, which is "basic interpolation".In general, this should not be an issue, but because
bumpversion
supports setting configuration in thesetup.cfg
file, options that might be interpolated by the parser would not cause an issue if they appear in the.bumpversion.cfg
, but suddenly break the install/build process if they are moved to thesetup.cfg
.For example, I had the following in my
.bumpversion.cfg
to automatically insert the date in my CHANGELOG along with the version.When I moved this into my
setup.cfg
,bumpversion
still works but the following happens when I try to run anything withsetup.py
.The obvious solution of escaping the
%
so that they are not interpolated (e.g.{now:%%m-%%d-%%Y}
causessetuptools
to not fail, but thenbumpversion
inserts the literal string "%%m-%%d-%%Y
" instead of formatting the date because the percent signs are not treated as needing escaping.It turns out that other packages have run into this, like
pytest
: https://github.com/pytest-dev/pytest/issues/3062. Thisdistutils
mailing thread also illustrates that the python devs are struggling with if this was a good design decision, but that's a whole other can of worms.My proposal: When loading from
setup.cfg
, useconfigparser.ConfigParser
, and when loading from.bumpversion.cfg
, useconfigparser.RawConfigParser
.