fix: make --help return before heavy runtime imports (#293)
Some checks failed
CI / Check and build (Python 3.10) (push) Has been cancelled
CI / Check and build (Python 3.11) (push) Has been cancelled
CI / Check and build (Python 3.12) (push) Has been cancelled
CI / Check and build (Python 3.13) (push) Has been cancelled

This commit is contained in:
Darshan 2026-04-12 16:33:30 +05:30 • committed by GitHub
parent e2c74bfb3c
commit cd422bbb99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,6 +3,20 @@
# ruff: noqa: E402
import sys
from .config import Settings
def _is_help_invocation() -> bool:
args = sys.argv[1:]
return "-h" in args or "--help" in args
# Parse and handle CLI help before importing heavyweight ML/runtime dependencies.
if _is_help_invocation():
Settings() # ty:ignore[missing-argument]
from .progress import patch_tqdm
# This patches tqdm class definitions, which must happen
@ -13,7 +27,6 @@ import logging
import math
import os
import random
import sys
import time
import warnings
from dataclasses import asdict
@ -45,7 +58,7 @@ from rich.table import Table
from rich.traceback import install
from .analyzer import Analyzer
from .config import QuantizationMethod, Settings
from .config import QuantizationMethod
from .evaluator import Evaluator
from .model import AbliterationParameters, Model, get_model_class
from .system import empty_cache, get_accelerator_info