open question about what to do when multiple linte...
# general
h
open question about what to do when multiple linters sometimes need to make sequential changes. e.g. we have
Copy code
def foo(arg: Union[str, list]):
formatting the file with our linters will allow all of them to pass except
pyupgrade
, which changes the line to
Copy code
def foo(arg: str | list):
unfortunately, we still need to run our formatters once more, since now we’ve got an unused
Copy code
from typing import Union
at the top of the file, which
autoflake
complains about. is there a better flow here that doesn’t require running our formatters twice or more times in a row? can we optimize this somehow so that some linters always run before other linters, so that in most cases they’d fix both issues in a single pass?
b
IIRC the order they are listed in
pants.toml
is the order they run in
fmt
1
h
do you know if anyone has looked into the optimal order to run formatters to reduce the likelihood of needing to do a rerun?
b
FWIW We're looking into making a dedicated
fix
goal for non-style changes. In this case you'd run
fix
before
fmt
👍 1
h
nice, so i think tools which would go under
fix
should be run first, followed by
fmt
. i’m thinking a good order would be
Copy code
pyupgrade
autoflake
docformatter
isort
black
2
h
There is probably a single fixed order that will work in practice, but in theory, we'd need to run tools repeatedly until the result converges, as nothing guarantees that a single fixed order exists