I'm using Databricks Runtime 13.3 LTS ML and for some reason the "Format document" black formatting is not adding a newline to the end of (python) file.
However, running same version of black locally, the newline is added.
Is there a way to force Databricks to add the newline?
Actually, the newline is added to the file when you format the document, but in Databricks, when you check, it seems like a newline is not added.
Below is the code in
.py
in local.After re-formatting, you will see 15 lines, and the 15th is the newline.
But the same thing in Databricks shows 14 lines like below after re-formatting.
This is because whenever you calculate the number of lines, it gives a count of 1 less than expected, as it only counts when it reads the
\n
character. In line 15, there is no\n
character, so it gives 14, but when you check it in anIDE
, you will see newline. However, internally, the newline is added in both Databricks and locally.