Skip to content

Commit 647c8ac

Browse files
committed
feat: adding 'lint' subcommand to commands.py for code checking
1 parent c9047c5 commit 647c8ac

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

codegen/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ def preprocess_schema(plotly_schema):
8585
items["colorscale"] = items.pop("concentrationscales")
8686

8787

88+
def lint_code():
89+
"""Check Python code using settings in pyproject.toml."""
90+
91+
subprocess.call(["ruff", "check", "."])
92+
93+
8894
def reformat_code():
8995
"""Reformat Python code using settings in pyproject.toml."""
9096

commands.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import sys
1212
import time
1313

14-
from codegen import perform_codegen, reformat_code
14+
from codegen import perform_codegen, lint_code, reformat_code
1515

1616

1717
LOGGER = logging.getLogger(__name__)
@@ -297,6 +297,8 @@ def parse_args():
297297
"--noformat", action="store_true", help="prevent reformatting"
298298
)
299299

300+
p_lint = subparsers.add_parser("lint", help="lint code")
301+
300302
p_format = subparsers.add_parser("format", help="reformat code")
301303

302304
p_updateplotlyjsdev = subparsers.add_parser(
@@ -319,6 +321,9 @@ def main():
319321
elif args.cmd == "format":
320322
reformat_code()
321323

324+
elif args.cmd == "lint":
325+
lint_code()
326+
322327
elif args.cmd == "updateplotlyjsdev":
323328
update_plotlyjs_dev()
324329

0 commit comments

Comments
 (0)