Hi, I have some lint questions. I got the black fa...
# general
h
Hi, I have some lint questions. I got the black failed report as follows.
Copy code
% pants lint ::
10:28:33.91 [INFO] Completed: Format with Black - black made no changes.
10:28:33.91 [INFO] Completed: Lint with Flake8 - flake8 succeeded.
Partition: ['CPython<4.0,>=3.8']


10:28:33.91 [INFO] Completed: Format with docformatter - docformatter made no changes.
10:28:33.91 [WARN] Completed: Format with Black - black made changes.
  src/python/text_streaming_service/text_streaming_service.py
  test/python/tests/text_streaming_service/test_text_streaming_service.py
10:28:33.92 [INFO] Completed: Format with isort - isort made no changes.

✕ black failed.
✓ docformatter succeeded.
✓ flake8 succeeded.
✓ isort succeeded.

(One or more formatters failed. Run `pants fmt` to fix.)
Then I run fmt:
Copy code
% pants fmt ::
10:30:29.58 [WARN] Completed: Format with isort - isort made changes.
  src/python/text_streaming_service/text_streaming_service.py
  test/python/tests/text_streaming_service/test_text_streaming_service.py
10:30:29.58 [INFO] Completed: Format with docformatter - docformatter made no changes.
10:30:29.58 [WARN] Completed: Format with Black - black made changes.
  src/python/text_streaming_service/text_streaming_service.py
  test/python/tests/text_streaming_service/test_text_streaming_service.py
10:30:29.58 [INFO] Completed: Format with Black - black made no changes.

+ black made changes.
✓ docformatter made no changes.
+ isort made changes.
Then I ran
pants lint ::
again, but it still shows
black failed
. do you know why? And what the exact error black report?
Anyone know the issue? I have to turn off
black
because of this.
b
Hard to tell without seeing the actual changes (and configuration possibly). But IIRC, there is some incompatibility between black's default behaviour and isort. I think black has a switch for isort compatibility.
c
Possibly not a helpful reply, but I've replaced black, isort and flake8 with ruff. It's so fast that i run it outside of pants across the whole repo in CI.
e
I can confirm what @breezy-twilight-65275 mentions. For clarity, try running
pants fmt --isort-skip ::
and then
git diff
and you should be able to see the changes made by
black
(which are getting reverted by `isort`; note your output from
fmt
has
black
making changes and then
isort
making changes after) Personally, I use
isort
with the
--profile=black
arg and that cleans up most confusion.
h
Thanks a lot. I will have a try
--profile=black
works
1
e
Glad it works for you!