diff --git a/pyproject.toml b/pyproject.toml index 7a74077..c85d9f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,3 +52,7 @@ src = ["src"] [tool.ruff.lint] select = ["E", "F", "I"] +ignore = ["E501"] + +[tool.ruff.lint.per-file-ignores] +"pack.py" = ["E501"] diff --git a/src/foreignthon/cli.py b/src/foreignthon/cli.py index b2b5e82..4fa694d 100644 --- a/src/foreignthon/cli.py +++ b/src/foreignthon/cli.py @@ -7,7 +7,7 @@ import click from . import __version__ from .errors import activate -from .transpiler import transpile_file, run_transpiled +from .transpiler import run_transpiled, transpile_file @click.group() @@ -20,7 +20,7 @@ def main(): @main.command() @click.argument("file", type=click.Path(exists=True, path_type=Path)) @click.option("--lang", "-l", default=None, help="Override language code (e.g. es, ta)") -@click.option("--keep", is_flag=True, help="Keep the compiled .py file alongside the source") +@click.option("--keep", is_flag=True, help="Keep the compiled .py alongside the source") def run(file: Path, lang: str | None, keep: bool): """Transpile and run a foreign-language Python file.""" if lang: @@ -44,12 +44,15 @@ def run(file: Path, lang: str | None, keep: bool): @main.command() @click.argument("file", type=click.Path(exists=True, path_type=Path)) -@click.option("--output", "-o", default=None, help="Output path (default: same dir as source)") +@click.option("--output", "-o", default=None, help="Output path (default: beside source)") def compile(file: Path, output: str | None): """Transpile a file to standard Python without running it.""" transpiled = transpile_file(file) - out_path = Path(output) if output else file.with_suffix("").with_suffix(".compiled.py") + out_path = ( + Path(output) if output + else file.with_suffix("").with_suffix(".compiled.py") + ) out_path.write_text(transpiled, encoding="utf-8") click.echo(f"Compiled: {out_path}") @@ -77,6 +80,7 @@ def check(file: Path): def validate_pack(json_file: Path): """Validate a language pack JSON file.""" import json + from .pack import REQUIRED_SECTIONS with open(json_file, encoding="utf-8") as f: diff --git a/src/foreignthon/errors.py b/src/foreignthon/errors.py index 7f88d5a..802ef89 100644 --- a/src/foreignthon/errors.py +++ b/src/foreignthon/errors.py @@ -3,7 +3,7 @@ from __future__ import annotations import sys import traceback -from .pack import load_pack, PackNotFoundError +from .pack import PackNotFoundError, load_pack _active_lang: str | None = None