Opened 4 years ago
Last modified 4 years ago
#33387 closed Cleanup/optimization
Separate between words in Django commands — at Initial Version
| Reported by: | אורי | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I checked the list of Django commands, and a long time ago I noticed that many of them contain two or even three words but they are not separated. For example makemigrations, makemessages, changepassword and createsuperuser. Although I found commands with separated words such as remove_stale_contenttypes (which I was not aware of until right now). I checked PEP 8 and there it is written:
Function names should be lowercase, with words separated by underscores as necessary to improve readability.
Variable names follow the same convention as function names.
I think Django commands should follow the same logic, and separate words by underscores (make_migrations, make_messages, change_password and create_super_user, remove_stale_content_types). I suggest that you add the new spelling while keeping the old spelling working, or maybe deprecate the old spelling but for at least 3 Django releases, so they will still work. But according to PEP 8 I think words should be separated by underscores.
This is also relevant to TestCase methods such as setUp and tearDownClass. Although there I assume Django inherits them from Python the language, and maybe the changes should be done also there.
By the way, I already defined a few such commands in Speedy Net since 2019:
https://github.com/speedy-net/speedy-net/tree/master/speedy/core/base/management/commands