forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds a `fix` goal, whose implementation is **literally** a copy-and-rename of `fmt`, along with the requisite `lint` changes. This, of course, isn't the long-term solution, but we need to discuss the relationship between the two, which informs how to implement all the "helper"/shared code. Also moved `autoflake` and `pyupgrade` to be fixers. Future PRs will clean up the duplication, and move `BUILD` file fixing from `update-build-files` here. Tested by "moving" `autoflake`, and running a few commans (`fix`, `lint`). Docs change(s) can come later, aside from what's in this PR (if anything). [ci skip-rust] [ci skip-build-wheels]
- Loading branch information
1 parent
c2166c5
commit c455a03
Showing
15 changed files
with
1,159 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 8 additions & 6 deletions
14
src/python/pants/backend/experimental/python/lint/autoflake/register.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
"""Autoformatter for removing unused Python imports. | ||
import logging | ||
|
||
See https://github.com/myint/autoflake for details. | ||
""" | ||
from pants.backend.python.lint.autoflake.register import rules as autoflake_rules | ||
|
||
from pants.backend.python.lint.autoflake import rules as autoflake_rules | ||
from pants.backend.python.lint.autoflake import skip_field, subsystem | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def rules(): | ||
return (*autoflake_rules.rules(), *skip_field.rules(), *subsystem.rules()) | ||
logger.warning( | ||
"DEPRECATED: The autoflake plugin has moved to `pants.backend.python.lint.autoflake`" | ||
+ " (and from the `fmt` goal to the `fix` goal)." | ||
) | ||
return autoflake_rules() |
15 changes: 9 additions & 6 deletions
15
src/python/pants/backend/experimental/python/lint/pyupgrade/register.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
"""https://github.com/asottile/pyupgrade. | ||
|
||
A tool to automatically upgrade syntax for newer versions of the language. | ||
""" | ||
import logging | ||
|
||
from pants.backend.python.lint.pyupgrade import rules as pyupgrade_rules | ||
from pants.backend.python.lint.pyupgrade import skip_field, subsystem | ||
from pants.backend.python.lint.pyupgrade.register import rules as pyupgrade_rules | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def rules(): | ||
return (*pyupgrade_rules.rules(), *skip_field.rules(), *subsystem.rules()) | ||
logger.warning( | ||
"DEPRECATED: The pyupgrade plugin has moved to `pants.backend.python.lint.pyupgrade`" | ||
+ " (and from the `fmt` goal to the `fix` goal)." | ||
) | ||
return pyupgrade_rules() |
14 changes: 14 additions & 0 deletions
14
src/python/pants/backend/python/lint/autoflake/register.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
"""Autoformatter for removing unused Python imports. | ||
See https://github.com/myint/autoflake for details. | ||
""" | ||
|
||
from pants.backend.python.lint.autoflake import rules as autoflake_rules | ||
from pants.backend.python.lint.autoflake import skip_field, subsystem | ||
|
||
|
||
def rules(): | ||
return (*autoflake_rules.rules(), *skip_field.rules(), *subsystem.rules()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/python/pants/backend/python/lint/pyupgrade/register.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
"""https://github.com/asottile/pyupgrade. | ||
A tool to automatically upgrade syntax for newer versions of the language. | ||
""" | ||
|
||
from pants.backend.python.lint.pyupgrade import rules as pyupgrade_rules | ||
from pants.backend.python.lint.pyupgrade import skip_field, subsystem | ||
|
||
|
||
def rules(): | ||
return (*pyupgrade_rules.rules(), *skip_field.rules(), *subsystem.rules()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.