Skip to content

Commit

Permalink
correct the isort and add an option to select a chosen path (facebook…
Browse files Browse the repository at this point in the history
…research#150)

Summary: Pull Request resolved: fairinternal/ssl_scaling#150

Reviewed By: prigoyal

Differential Revision: D28746516

Pulled By: QuentinDuval

fbshipit-source-id: 4c01512ec42aca4bc6832636fcc42c00f481c6fe
  • Loading branch information
QuentinDuval authored and facebook-github-bot committed Jun 1, 2021
1 parent f1ed150 commit 07d392d
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions dev/lint_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ def get_argument_parser():
default=False,
help="Running the linter on the whole repository",
)
parser.add_argument(
"-p",
"--path",
type=str,
default="",
help="Running the linter on a specific directory",
)
return parser


Expand Down Expand Up @@ -104,9 +111,9 @@ def run_sort_include_on(paths: Sequence[str], check_only: bool):
options = "-c" if check_only else ""
for path in paths:
if os.path.isdir(path):
_run_command(f"isort {options} -sp {path}")
_run_command(f"isort -sp . {options} -rc {path}")
elif path.endswith(".py"):
_run_command(f"isort {options} {path}")
_run_command(f"isort -sp . {options} {path}")


def run_flake8_on(paths: Sequence[str]):
Expand Down Expand Up @@ -149,11 +156,19 @@ def run_flake8_on(paths: Sequence[str]):
```
python dev/lint_commit.py --all --repo
```
To apply the checks on a subfolder:
```
python dev/lint_commit.py --all --path /path/to/format
```
"""
args = get_argument_parser().parse_args()

# Find the files and folders to impact with the checks
if not args.repo:
if args.path:
target_paths = [args.path]
elif not args.repo:
target_paths = get_list_of_impacted_files(os.getcwd())
else:
target_paths = [
Expand Down

0 comments on commit 07d392d

Please sign in to comment.