Skip to content

Commit

Permalink
Remove hardcoded argument from autoflake linter
Browse files Browse the repository at this point in the history
Move "--remove-all-unused-imports" to a default argument rather than a hardcoded
portion of the command for autoflake. This allows a user to override if the'd
prefer a more conservative run of autoflake.
  • Loading branch information
Thomas Dimiduk committed Jul 15, 2022
1 parent 1ef5a17 commit f9f10b7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/python/pants/backend/python/lint/autoflake/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ async def autoflake_fmt(request: AutoflakeRequest, autoflake: Autoflake) -> FmtR
autoflake_pex,
argv=(
"--in-place",
"--remove-all-unused-imports",
*autoflake.args,
*request.snapshot.files,
),
Expand Down
5 changes: 4 additions & 1 deletion src/python/pants/backend/python/lint/autoflake/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ class Autoflake(PythonToolBase):
default_lockfile_url = git_url(default_lockfile_path)

skip = SkipOption("fmt", "lint")
args = ArgsListOption(example="--target-version=py37 --quiet")
args = ArgsListOption(
example="--remove-all-unused-imports --target-version=py37 --quiet",
default=["--remove-all-unused-imports"],
)
export = ExportToolOption()


Expand Down
1 change: 1 addition & 0 deletions src/python/pants/option/option_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,7 @@ def __new__(
# This should be set when callers can alternatively use "--" followed by the arguments,
# instead of having to provide "--[scope]-args='--arg1 --arg2'".
passthrough: bool | None = None,
default: list[str] | None = None,
):
if extra_help:
extra_help = "\n\n" + extra_help
Expand Down

0 comments on commit f9f10b7

Please sign in to comment.