-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into pre-commit-ci-update-config
- Loading branch information
Showing
4 changed files
with
52 additions
and
32 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,22 @@ | ||
"""Add "lint" action for the "gepetuto" program.""" | ||
|
||
import logging | ||
from pathlib import Path | ||
from subprocess import check_call | ||
from typing import List | ||
|
||
LOG = logging.getLogger("gepetuto.lint") | ||
|
||
|
||
def lint(tp_id: List[int], **kwargs): | ||
def lint(files, **kwargs): | ||
"""Lint python scripts.""" | ||
LOG.info("linting tutorial sources.") | ||
for n in tp_id: | ||
LOG.debug(f"Looking for tp {n}") | ||
lint_tp_folder(n) | ||
for f in files: | ||
lint_folder(f) | ||
LOG.info("lint done.") | ||
|
||
|
||
def lint_tp_folder(tp_number): | ||
"""Lint python scripts for a given tp_number.""" | ||
LOG.debug(f"Looking for tp {tp_number}") | ||
folder = Path(f"tp{tp_number}") | ||
for python_file in folder.glob("*.py"): | ||
LOG.debug(f"Checking {python_file}") | ||
check_call(["isort", python_file]) | ||
check_call(["black", python_file]) | ||
check_call(["ruff", "--fix", python_file]) | ||
def lint_folder(file): | ||
"""Lint python scripts in folder.""" | ||
LOG.debug(f"Checking {file}") | ||
check_call(["isort", file]) | ||
check_call(["black", file]) | ||
check_call(["ruff", "--fix", file]) |
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