https://pantsbuild.org/ logo
c

curved-television-6568

10/09/2021, 6:31 AM
@polite-garden-50641 Hi, I thought I would run pyupgrade on the docker backend. Is it as easy as just
./pants fmt src/…
from your pyupgrade branch?
p

polite-garden-50641

10/09/2021, 2:02 PM
Yep. But you have to run “fmt” twice since because pyupgrade will change the type annotation syntax and will make some imports unnecessary another run is required so autoflake can get rid of those.
I think there is probably a way to work around it by sorting the backends differently, but I didn't look into it
c

curved-television-6568

10/09/2021, 2:56 PM
Cool, thanks. Will give it a go 🙂
h

hundreds-father-404

10/09/2021, 2:59 PM
Yes, the ordering does matter in pants.toml. I recommend pyupgrade first, then Autoflake, then the rest
h

happy-kitchen-89482

10/09/2021, 5:26 PM
Should document that when we document pyupgrade?
1
👍 1
h

hundreds-father-404

10/09/2021, 5:28 PM
and probably write a better test to guarantee we don't break this. Iirc we were talking about ordering of rule registration last month and it was only Stu who remembered it does matter. We could have easily broken that feature
🤭 1
c

curved-television-6568

10/12/2021, 7:47 AM
OK, tried it, and came out with no changes 🎉 However, just to make sure I used it right, tried it on another source file, and noticed the fact it ran last
Copy code
$ ./pants --backend-packages=pants.backend.python.lint.pyupgrade fmt src/python/pants/option/arg_splitter_test.py
Could there perhaps be a way (or is there, and I just don’t know about it?) to have the packages listed on the command line added to the front, rather than the end of the list?