Operating system: Ubuntu 18.04
Python version: 3.6.3
Black version: master
Thank you @ambv for this library. When trying to run this on a codebase that uses tabs, indentation for comments past depth 0 is changed incorrectly after a dedent. Sample input (NB tabs):
if 1:
if 2:
pass
# This comment should be indented the same as the next line
pass
Black reformats this to:
if 1:
if 2:
pass
# This comment should be indented the same as the next line
pass
Note that this only happens when the input file uses tabs.
Probably related. Here is another example:
In [1]: import black
In [2]: black.__version__
Out[2]: '18.6b2'
In [3]: cat test_if.py
if True:
print("A1")
# print("A2")
else:
print("B1")
# print("B2")
In [4]: cat test_if_black.py
if True:
print("A1")
# print("A2")
else:
print("B1")
# print("B2")
test_if.py is the original file and test_if_black.py is the reformatted version.
@ambv I've opened a PR (#595) that fixes this issue and includes a minimal reproduction as a test case. Thanks again for this project!
As an aside, I would implore you to please re-consider adding support for tabs - this feature is the one thing that is blocking our team from using Black. (In the meantime, we will be using @jleclanche's fork.)
Most helpful comment
@ambv I've opened a PR (#595) that fixes this issue and includes a minimal reproduction as a test case. Thanks again for this project!
As an aside, I would implore you to please re-consider adding support for tabs - this feature is the one thing that is blocking our team from using Black. (In the meantime, we will be using @jleclanche's fork.)