click: Command names with underscores must be invoked with dashes instead when upgrading from 6.7 to 7.0
Click 7.0 is breaking upstream packages, in our case mschematool (issue reported there: https://github.com/aartur/mschematool/issues/11).
After upgrading from 6.7 to 7.0, the init_db command can no longer be found.
$ mschematool xyz init_db
Usage: mschematool [OPTIONS] DBNICK COMMAND [ARGS]...
Try "mschematool --help" for help.
Error: No such command "init_db".
ERROR: Job failed: exit code 2
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (11 by maintainers)
Commits related to this issue
- Update test for breaking change in click https://github.com/pallets/click/issues/1123 — committed to pypi/warehouse by di 6 years ago
- Update click to 7.0 (#4764) * Update click from 6.7 to 7.0 * Update click from 6.7 to 7.0 * Update test for breaking change in click https://github.com/pallets/click/issues/1123 — committed to pypi/warehouse by pyup-bot 6 years ago
- Require click version >=7 (#503) The command line interface is different for versions <7 (underscores instead of dash, see https://github.com/pallets/click/issues/1123). The documentation only docume... — committed to azogue/python-miio by fvollmer 5 years ago
- explicitly specify command with underscores Starting click 7.0. The default behavior of a command with under scores will be replace with dashes. this is to address the above default behavior change,... — committed to lguohan/sonic-utilities by lguohan 4 years ago
- explicitly specify command with underscores (#846) Starting click 7.0. The default behavior of a command with under scores will be replace with dashes. this is to address the above default behavi... — committed to sonic-net/sonic-utilities by lguohan 4 years ago
- explicitly specify command with underscores (#846) Starting click 7.0. The default behavior of a command with under scores will be replace with dashes. this is to address the above default behavi... — committed to sonic-net/sonic-utilities by lguohan 4 years ago
- normalize commands with underscores to dashes compat patch for click >= 7.0. see https://github.com/pallets/click/issues/1123 — committed to ClimateImpactLab/jrnr by delgadom 4 years ago
- explicitly specify command with underscores (#846) Starting click 7.0. The default behavior of a command with under scores will be replace with dashes. this is to address the above default behavi... — committed to abdosi/sonic-utilities by lguohan 4 years ago
You can still use underscores by specifying the command names explicitly. It’s just that the default is now to replace with dashses, to look more consistent with other CLI tools, whereas before you would have had to specify those explicitly.
So if you want to upgrade your app to 7.0 but continue using the old names, you can name them explicitly, or use a
Commandsubclass that doesn’t have the new behavior. There are upgrade strategies here, it just means Click 7.0 is not a drop-in upgrade in some cases.@davidism thanks for the commit ref and the explanation. I think it could have been more prominently described in the changelog (given python naming conventions would imply an insignificant number of people would hit this) but I do understand it was a major release. On our side, probably we should have pinned our dependencies better -_-.
perhaps it makes sense to attempt both for some interim period? of course, you’d have to dedupe (and raise some exception) when someone goes wild and attempts to register both styles…
@di nice to see you!