Reproducible black --help
output for --python-cell-magics
option
#3515
Labels
black --help
output for --python-cell-magics
option
#3515
Describe the bug
When calling
black --help
repeatedly, the output returned is not the same. The description text for option--python-cell-magics
includes an enumeration for a list of know python-magics, but the order of the element is always different.To Reproduce
black --help
.black --help
.The changes can look like:
Expected behavior
If there is no changes in Black's version, then there shouldn't be changes in the
black --help
output.Environment
so,
uname -a
givesLinux codespaces-391ca7 5.4.0-1098-azure #104~18.04.2-Ubuntu SMP Tue Nov 29 12:13:35 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
, and it is using Python 3.10.4 (``python -V`)Additional context
Here comes the "why".
When tools or doc generators keep the output of the help in its files, it leads to always having two lines of diff for the python-cell-magics in a different order, but always the same set. More specifically, in a project like MegaLinter, each build will have changes for black, even when no changes are made to black. Take a look at any PR with a name starting with "[automation] Auto-update linters version, help and documentation" in https://github.com/oxsecurity/megalinter/pulls?&q=is%3Apr+is%3Aclosed+label%3Adependencies+label%3Aautomerge and look at the changed files. A similar problem was reported for Flake8 last year at PyCQA/flake8#1550 and got fixed in PyCQA/flake8#1552. However, for here the changes to solve the problem is as easy as changing one line that was introduced in #2744:
In
black/src/black/__init__.py
Lines 242 to 251 in c5df7b7
we can use
', '.join(sorted(PYTHON_CELL_MAGICS))
instead of', '.join(PYTHON_CELL_MAGICS)
, for a non-breaking change.If you accept, I could write a trivial PR for this, but I was writing an issue first!
Thanks for your time!
The text was updated successfully, but these errors were encountered: