diff --git a/check.sh b/check.sh new file mode 100755 index 0000000..7786dc5 --- /dev/null +++ b/check.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +BASE_DIR="src" + +echo "#============#" +echo "# Ruff #" +echo "#============#" +(cd "$SCRIPT_DIR" && ruff check "$BASE_DIR") +echo +echo +echo "#============#" +echo "# Ty #" +echo "#============#" +(cd "$SCRIPT_DIR" && uvx ty check "$BASE_DIR") diff --git a/src/dcr/cli/build.py b/src/dcr/cli/build.py index 637d714..d9e9b30 100644 --- a/src/dcr/cli/build.py +++ b/src/dcr/cli/build.py @@ -1,7 +1,7 @@ import time import os import subprocess -from ..config import flags, profile, c_comp +from ..config import flags, profile, project_compiler from ..utils.fs import check_dir from ..utils.text import colored, BRIGHT_GREEN, BOLD, BRIGHT_RED @@ -30,7 +30,7 @@ def build(args: list[str] | None = None) -> int: + "`\n Профиль: " + colored(active_profile, BRIGHT_GREEN + BOLD) + "\n Компилятор: " - + colored(c_comp, BRIGHT_GREEN + BOLD) + + colored(project_compiler, BRIGHT_GREEN + BOLD) + "\n" ) @@ -44,7 +44,7 @@ def build(args: list[str] | None = None) -> int: try: subprocess.run( [ - c_comp, + project_compiler, "./src/main.c", *compile_flags, "-o", @@ -63,7 +63,7 @@ def build(args: list[str] | None = None) -> int: + " секунд" ) return 0 - except: + except: # noqa: E722 print(colored("error", BRIGHT_RED + BOLD) + ": сборка не удалась") return 1 diff --git a/src/dcr/cli/init.py b/src/dcr/cli/init.py index 3bcdb12..25afa83 100644 --- a/src/dcr/cli/init.py +++ b/src/dcr/cli/init.py @@ -26,7 +26,7 @@ def init(args: list[str] | None = None) -> int: print("Инициализация проекта в " + os.getcwd()) - with open(f"./dcr.toml", "w") as file: + with open("./dcr.toml", "w") as file: file.write( file_dcr_toml.format( project_name=project_name, diff --git a/src/dcr/cli/run.py b/src/dcr/cli/run.py index e803bc7..145137b 100644 --- a/src/dcr/cli/run.py +++ b/src/dcr/cli/run.py @@ -1,5 +1,4 @@ import subprocess -import os from ..utils.fs import check_dir from ..utils.text import colored, BRIGHT_RED, BOLD @@ -8,7 +7,6 @@ from .build import build def run(args: list[str] | None = None) -> int: - project_name = os.path.basename(os.getcwd()) active_profile: str = profile if "dcr.toml" not in check_dir(): print(colored("error", BRIGHT_RED + BOLD) + ": не найден файл dcr.toml") diff --git a/src/dcr/config.py b/src/dcr/config.py index 20aebf5..032d7d4 100644 --- a/src/dcr/config.py +++ b/src/dcr/config.py @@ -35,10 +35,9 @@ project_language: str = "c" project_compiler: str = "clang" profile: str = "debug" -c_comp: str = "clang" flags: dict[str, list[str]] = { "release": ["-O3", "-DNDEBUG", "-march=native"], "debug": ["-O0", "-g", "-Wall", "-Wextra", "-fno-omit-frame-pointer", "-DDEBUG"], } -VERSION = "v0.1.1" \ No newline at end of file +VERSION = "v0.1.1" diff --git a/src/dcr/main.py b/src/dcr/main.py index 6a1c30a..338cbc9 100644 --- a/src/dcr/main.py +++ b/src/dcr/main.py @@ -1,5 +1,5 @@ from .config import VERSION -import dcr.cli as cli +import dcr.cli as cli # ty:ignore[unresolved-import] import sys