https://pantsbuild.org/ logo
#general
Title
# general
c

curved-television-6568

11/10/2021, 5:56 PM
I have an interesting
fmt
conflict between black and isort. 🧵
They can’t agree on how to format my imports.. Black wants to format it like
Copy code
+from graphene import (
+    UUID,
+    DateTime,
+    Enum,
+    Field,
+    InputObjectType,
+    Int,
+    Interface,
+    List,
+    ObjectType,
+    PageInfo,
+    Scalar,
+    String,
+    Union,
+    relay,
+)
while
isort
wants to format it like this
Copy code
-from graphene import (UUID, DateTime, Enum, Field, InputObjectType, Int,
-                      Interface, List, ObjectType, PageInfo, Scalar, String,
-                      Union, relay)
So
./pants lint
never pass as they don’t agree on the formatting here.. what am I missing (configuration?). I don’t think I have any particular config in place for either of these tools.
w

witty-crayon-22786

11/10/2021, 6:08 PM
i have seen flake8 and black fight over something too… ended up adding an ignore for one of them
oh. but also: i believe that you can configure isort to be black aware…?
🎯 2
👆 2
c

curved-television-6568

11/10/2021, 6:13 PM
Ah, there it was, I looked in the pants repo, but missed the pyproject file…
That’s a gotcha perhaps worth mentioning in the docs, how to use black and isort in tandem..
👍 1
Thanks Stu, that was spot on.
👍 1
w

witty-crayon-22786

11/10/2021, 6:44 PM
yea, doc updates welcome. pants proper strives for minimal configuration, but tool-specific config is a bit of a grey area… we could maybe add a warning if it’s not configured or something?
c

curved-television-6568

11/10/2021, 6:46 PM
I think docs will be good enough
@witty-crayon-22786 https://www.pantsbuild.org/v2.8/docs/python-linters-and-formatters#black-and-isort-can-work-together There is no way to save draft changes, besides the “public” suggest edits form, right?
w

witty-crayon-22786

11/10/2021, 7:33 PM
… i think that’s correct, yea.
c

curved-television-6568

11/10/2021, 7:37 PM
so with that, I wanted to say, that I added a section for “black and isort” config, that you might want to review 😉
w

witty-crayon-22786

11/10/2021, 7:44 PM
thank you!
looks great.
👍 1