File-specific line-endings misbehaviour when doing in-place black
I'm using a mac to contribute to a project that has python files with windows formatting CRLF. When I apply black to these files, black seems to break the line-end-formatting of the files. There's a possibly related issue with a solution, but doesn't seem to work properly in my situation.
To Reproduce
$ mkdir simple
$ cd simple
$ git init
$ printf "#black will touch this comment\n# black won't touch this comment\n#black will touch this comment\n# black won't touch this comment\n" > simple.py
$ unix2dos simple.py
$ git add simple.py && git commit -m "initial add" simple.py
$ black simple.py
$ git diff simple.py
diff --git a/simple.py b/simple.py
index cf57a10..886c794 100644
--- a/simple.py
+++ b/simple.py
@@ -1,4 +1,4 @@
-#black will touch this comment
+# black will touch this comment^M
# black won't touch this comment
-#black will touch this comment
+# black will touch this comment^M
# black won't touch this comment
Expected behavior
Same output as above but without the "^M" at the ends.
Environment
- Black's version: black, 22.10.0 (compiled: yes)
- OS and Python version: macOS 12.6 (Monterey) / Python 3.10.4
File-specific line-endings misbehaviour when doing in-place black
I'm using a mac to contribute to a project that has python files with windows formatting CRLF. When I apply
blackto these files,blackseems to break the line-end-formatting of the files. There's a possibly related issue with a solution, but doesn't seem to work properly in my situation.To Reproduce
Expected behavior
Same output as above but without the "
^M" at the ends.Environment