I'll add too, I'm strongly opinionated that Python...
# welcome
b
I'll add too, I'm strongly opinionated that Python needs more "fixers" tooling. Not saying I'm going write a framework or anything, but...
h
Can you explain this more, please? We recently added an
update-build-files
goal which is kind of like a Buildozer-lite!
b
Yeah I just mean generically in the ecosystem. More tools like
isort
which don't just complain but also fix issues. E.g.
flake8-simplify
says "don't nest these if statements". OK, then fix it for me! ๐Ÿ˜‚
h
Ah, you may be excited that Pants 2.8 adds Autoflake and Pyupgrade into the mix! Those automate fixing semantic issues, like unused imports
We're almost always happy to add more tools if you know of any
๐Ÿ˜‚ 1
b
I juuust ran across `eradicate`https://github.com/myint/eradicate
๐Ÿ‘€ 1
Looks like the same author as
autoflake
time to go sniff their GitHub ๐Ÿ˜‚
h
Interesting! Adding that is pretty simple to do, mostly copy pasta. @polite-garden-50641 @happy-kitchen-89482 any thoughts on adding this to core Pants? Only 100 stars and it hasn't been updated in 13 months, but still might be worth it
b
Fair point on "fomatter" vs "fixer" ๐Ÿ˜‰
โž• 1
h
we're right now thinking about having
./pants fix
vs.
./pants fmt
. For now, Pyupgrade and Autoflake are under
fmt
and there is no
fix
goal But we realized we want to merge other fixers like
./pants tailor
(add missing target definitions) into a single goal, and that definitely should not be happening in
./pants fmt
. I think
./pants fix
makes sense Punted on the question for the upcoming Pants 2.8 release by making Pyupgrade and Autoflake be experimental backends so that we can change from
fmt
to
fix
later if we decide to
p
specifically on
eradicate
I don't think it is worth adding to be a core part of pants... this doesn't seem to be the tool you need to keep running on an ongoing bases... Not allowing commented out code is a tricky issue. I don't think this is useful. this (commented out code) is the kind of thing that should be left for humans to decide on a case by case basis. IMHO. enforcing such a policy on the repo level seems heavy handed.
๐Ÿ‘ 1
โž• 2
h
Thanks, Asher! Agreed, makes sense to me. @bitter-ability-32190 lmk if you'd be interested in developing as an internal plugin for your org, though! Happy to give some pointers on how to do that
b
My personal hot take on format-vs-fix: If it's safe to do on save. Format is safe to do on save because ideally it isn't altering the file in a semantic way Fixing isn't safe to do on save because it does. (E.g. I add an import which I haven't used yet and hit save. I'd be really annoyed if it disappeared)
โž• 1
h
Ohhh that's a really excellent point with
./pants --loop fmt
@witty-crayon-22786 , which reruns that goal when changes to relevant files are made
w
mm, yea: interesting. i use
./pants --loop check fmt lint
, so
fmt
doesnโ€™t happen until typechecking passesโ€ฆ that eliminates many of those concerns, but would still totally nuke an unused import, heh.
but IDE users are probably saving more frequently
โž• 1
c
Iโ€™d love a tool that also would add any missing imports for me. That would eliminate the unused import nuke issue.
b
That is simply one example. To add another one: unused variable nuking ๐Ÿ˜‰ (add a variable because I'm the human writing code, save because I'm neurotic, blammo)
๐Ÿ‘ 1