Skip to content

fix(cli): CLI help --max_length should be --max-length - #6

Merged
lomeliDev merged 1 commit into
masterfrom
issue/1-cli-help-max-length-should-be-max-length
Oct 14, 2026
Merged

lomeliDev merged 1 commit into
masterfrom
issue/1-cli-help-max-length-should-be-max-length

Conversation

@lomeliDev

Copy link
Copy Markdown
Owner

Summary

Fixes the CLI help text reported in #1. The --word-boundary and --save-order help strings referred to --max_length (underscore), but argparse registers the flag as --max-length (hyphen). A user copying the name from slugify --help gets error: unrecognized arguments: --max_length.

Root cause

slugify/__main__.py declares parser.add_argument("--max-length", ...), but the help strings of two sibling options hard-coded the underscore spelling --max_length. The --help output was the only wrong part; the parser itself was correct.

Change (minimal)

  • slugify/__main__.py: the two help strings now read --max-length.
  • tests/test_cli_interrupt.py: new regression test test_help_uses_hyphenated_max_length, exactly as requested in the issue's done criterion.

No CI workflow was modified. No auto-close keyword is used; Issue #1 is only referenced.

Evidencia (vista roja / verde)

ROJO — new test kept, fix removed from slugify/__main__.py (pre-fix code):

$ python -m pytest tests/test_cli_interrupt.py::test_help_uses_hyphenated_max_length -q
F                                                                    [100%]
=================================== FAILURES ===================================
_____________________ test_help_uses_hyphenated_max_length _____________________

capsys = <_pytest.capture.CaptureFixture object at 0x...>

    def test_help_uses_hyphenated_max_length(capsys):
        with pytest.raises(SystemExit):
            cli.main(['slugify', '--help'])
        out = capsys.readouterr().out
>       assert '--max_length' not in out
E       assert '--max_length' not in 'usage: __ma...from STDIN\n'
E         '--max_length' is contained here:
E           rter than --max_length
E             --save-order          When set and --max_length > 0 return whole words in
E                                   the initial order
...
1 failed in 0.07s

VERDE — same test with the fix in place:

$ python -m pytest tests/test_cli_interrupt.py::test_help_uses_hyphenated_max_length -q
.                                                                    [100%]
1 passed in 0.03s

Quality gate (repo)

Run in an isolated temporary venv (the base system interpreter lacked text-unidecode, a pre-existing environment gap unrelated to this change):

$ python -m pytest -q
134 passed, 5 skipped, 136 subtests passed in 0.58s

$ flake8 --ignore=E501,F403,F401,E241,E225,E128 --exclude=legacy_reference.py slugify setup.py tests tools
(clean)

$ pycodestyle --ignore=E128,E261,E225,E501,W605 --exclude=legacy_reference.py slugify tests setup.py tools
(clean)

$ python -m mypy
Success: no issues found in 6 source files

Lección de memoria / propagación

No durable-memory lesson matched this case: lissa_recall and lissa_search (lexical/degraded mode) returned no hits for the CLI/argparse flag case. A repo-wide grep for --max_length confirms its only occurrences were exactly the two CLI help strings fixed here; the remaining max_length hits are the Python API parameter (slugify(..., max_length=...), smart_truncate, docs/tests), which are not CLI flags and are intentionally left unchanged. No out-of-scope sibling path was found.

Sonda de choque

python3 .../choque.py ... origin master --repo lomeliDev/python-slugify → SIN CHOQUE (no rebase needed).

🚀 Generated with Dojo ⛩️

The --word-boundary and --save-order help strings referred to a
--max_length (underscore) flag that argparse does not register; copying
the name from the help yields "unrecognized arguments". Use the actual
--max-length spelling and add a regression test that captures the
parser help.

Refs #1
@lomeliDev

Copy link
Copy Markdown
Owner Author

Revisión adversarial — VEREDICTO: APROBABLE

Revisión independiente (checkout limpio de la rama, venv propio). Python 3.11.2, TMPDIR=/tmp.

Hallazgos verificados (con prueba):

  • Ninguno bloqueante ni serio.

Intentos de romperlo que NO prosperaron:

  • ¿Rojo sin el arreglo? Sí. Revertí las dos cadenas de ayuda a --max_length (dejando el test) y, limpiando __pycache__:
    $ python -m pytest tests/test_cli_interrupt.py::test_help_uses_hyphenated_max_length -q
      FAILED  AssertionError: assert '--max_length' not in 'usage: ...'
    
    Con el arreglo y pyc limpio: 1 passed. El test mide la salida real de --help, no la forma.
  • ¿Alcance? git diff --stat origin/master...HEAD = sólo slugify/__main__.py (+2/-2) y tests/test_cli_interrupt.py (+8). Coincide con Archivos:.
  • ¿Toca legacy / contrato congelado? No. slugify/_legacy.py y slugify.py intactos; no hay cambio conductual de slug. Las demás apariciones de max_length son el parámetro de la API Python (max_length=…), no flags CLI, y quedan sin tocar (correcto).
  • ¿Regresión? Suite completa (pyc limpio): 134 passed, 5 skipped, 136 subtests (133 base + 1 nuevo).

Aviso de entorno (no es del PR): ojo al revisar en local — un .pyc viejo de slugify/__main__ sirve bytecode rancio tras editar las cadenas y puede dar un rojo/verde falso; hay que borrar __pycache__ entre corridas. No afecta al PR.

Lo que no pude verificar: tox/matriz completa (pypy, 3.12–3.14, mypy estricto) — fuera de presupuesto; el taller-ci del PR (py3.11/3.12 + flake8 + pycodestyle + pytest) pasó en verde.

@lomeliDev
lomeliDev merged commit 4ec5225 into master Oct 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant