In the alembic.ini templates, I moved the inline comment about version_path_separator to their own lines as required by configparser.
Description
In a recent project, I included the following configuration values in my alembic.ini. Note that the last line is the default line from the current generic alembic.ini template.
# version location specification; This defaults
# to migrations/versions. When using multiple version
# directories, initial revisions must be specified with --version-path.
# The path separator used here should be the separator specified by "version_path_separator" below.
version_locations = %(here)s/migrations/versions
# version path separator; As mentioned above, this is the character used to split
# version_locations. The default within new alembic.ini files is "os", which uses os.pathsep.
# If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas.
# Valid values for version_path_separator are:
#
# version_path_separator = :
# version_path_separator = ;
# version_path_separator = space
version_path_separator = os # Use os.pathsep. Default configuration used for new projects.
When running alembic check, I encountered:
ValueError: 'os # Use os.pathsep. Default configuration used for new projects.' is not a valid value for version_path_separator; expected 'space', 'os', ':', ';'
It seemed that the comment in the last line was being included as part of the parsed config value, which should be os.
Alembic currently uses configparser.ConfigParser from the standard libary to parse alembic.ini files. The default configparser file format requires that comments be on their own lines, although this can be customized. I changed the three copies of this line in Alembic's alembic.ini templates to remove the inline comments. In my case, this change fixed the ValueError.
This issue could also be fixed by changing the default instance of ConfigParser, using inline_comment_prefixes=("#",). I imagine, however, that it might be better to use the default file format.
Checklist
This pull request is:
[x] A documentation / typographical error fix
Good to go, no issue or tests are needed
[ ] A short code fix
please include the issue number, and create an issue if none exists, which
must include a complete example of the issue. one line code fixes without an
issue and demonstration will not be accepted.
Please include: Fixes: #<issue number> in the commit message
please include tests. one line code fixes without tests will not be accepted.
[ ] A new feature implementation
please include the issue number, and create an issue if none exists, which must
include a complete example of how the feature would look.
Please include: Fixes: #<issue number> in the commit message
In the
alembic.ini
templates, I moved the inline comment aboutversion_path_separator
to their own lines as required byconfigparser
.Description
In a recent project, I included the following configuration values in my
alembic.ini
. Note that the last line is the default line from the current genericalembic.ini
template.When running
alembic check
, I encountered:It seemed that the comment in the last line was being included as part of the parsed config value, which should be
os
.Alembic currently uses
configparser.ConfigParser
from the standard libary to parsealembic.ini
files. The defaultconfigparser
file format requires that comments be on their own lines, although this can be customized. I changed the three copies of this line in Alembic'salembic.ini
templates to remove the inline comments. In my case, this change fixed theValueError
.This issue could also be fixed by changing the default instance of
ConfigParser
, usinginline_comment_prefixes=("#",)
. I imagine, however, that it might be better to use the default file format.Checklist
This pull request is:
Fixes: #<issue number>
in the commit messageFixes: #<issue number>
in the commit messageHave a nice day!