Skip to content

[BUG] truncate_slug_length on pyproject.toml does't work #1709

@LuisHenri

Description

@LuisHenri

Describe the bug

Adding truncate_slug_length to pyproject.toml causes "FAILED: unsupported TOML value type for key: 'truncate_slug_length'" when running `alembic revision -m "message"``

Expected behavior

  1. For it to work
  2. For it to truncate the slug

To Reproduce

  1. initialize alembic with alembic init --template pyproject alembic --package
  2. Uncomment/add truncate_slug_length
  3. Run alembic revision -m "message"

pyproject.toml

[tool.alembic]

# path to migration scripts.
# this is typically a path given in POSIX (e.g. forward slashes)
# format, relative to the token %(here)s which refers to the location of this
# ini file
script_location = "%(here)s/alembic"

truncate_slug_length = 5
#...

Error

PS XXX> alembic  --raiseerr revision -m "Increase some columns length"
Traceback (most recent call last):
  File "XXX\AppData\Roaming\uv\python\cpython-3.10.18-windows-x86_64-none\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "XXX\AppData\Roaming\uv\python\cpython-3.10.18-windows-x86_64-none\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "XXX\.venv\Scripts\alembic.exe\__main__.py", line 10, in <module>
  File "XXX\.venv\lib\site-packages\alembic\config.py", line 1016, in main
    CommandLine(prog=prog).main(argv=argv)
  File "XXX\.venv\lib\site-packages\alembic\config.py", line 1006, in main
    self.run_cmd(cfg, options)
  File "XXX\.venv\lib\site-packages\alembic\config.py", line 940, in run_cmd
    fn(
  File "XXX\.venv\lib\site-packages\alembic\command.py", line 252, in revision
    script_directory = ScriptDirectory.from_config(config)
  File "XXX\.venv\lib\site-packages\alembic\script\base.py", line 179, in from_config
    tsl = config.get_alembic_option("truncate_slug_length")
  File "XXX\.venv\lib\site-packages\alembic\config.py", line 456, in get_alembic_option
    return self._get_toml_config_value(name, default=default)
  File "XXX\.venv\lib\site-packages\alembic\config.py", line 499, in _get_toml_config_value
    raise util.CommandError(
alembic.util.exc.CommandError: unsupported TOML value type for key: 'truncate_slug_length'

Versions.

  • OS: Windows 11 Business 24H2
  • Python: 3.10.18
  • Alembic: 1.16.4
  • SQLAlchemy: 1.4.54
  • Database: PostgreSQL
  • DBAPI: psycopg2==2.9.9

Have a nice day!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions