Reduce and tighten comments and docstrings across the test suite (#6429)
* Reduce and tighten comments and docstrings in tests Shorten verbose comments and docstrings across the test suite without changing any test logic. Remove narration that restates the next line, collapse long module and test docstrings to a single line, and drop banner separators. Keep regression context (issue and PR references, run ids), skip reasons, mocking and timing rationale, license headers, lint and type directives, and commented-out code. Comments and docstrings only: an AST signature check confirms no code, assertions, or string literals changed, and the suite byte-compiles cleanly. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
1b697ed6fc
commit
a6dc10dad2
122 changed files with 1847 additions and 4511 deletions
|
|
@ -1,8 +1,4 @@
|
|||
"""Tests that the 'unsloth studio' CLI defaults to 127.0.0.1.
|
||||
|
||||
Uses AST parsing to inspect source-level defaults without requiring the
|
||||
full unsloth_cli dependencies (typer/pydantic) at test-collection time.
|
||||
"""
|
||||
"""'unsloth studio' CLI must default --host to 127.0.0.1. AST-based, no typer/pydantic needed."""
|
||||
|
||||
import ast
|
||||
from pathlib import Path
|
||||
|
|
@ -11,12 +7,7 @@ _STUDIO_CMD_PY = Path(__file__).resolve().parents[2] / "unsloth_cli" / "commands
|
|||
|
||||
|
||||
def _find_typer_option_default(source: str, func_name: str, long_option: str):
|
||||
"""Return the default value of a typer.Option(...) parameter in *func_name*.
|
||||
|
||||
Matches by the long option name (e.g. '--host') among the positional args
|
||||
of the typer.Option() call and returns the first positional arg (the
|
||||
default value). Only handles ast.Constant defaults.
|
||||
"""
|
||||
"""Return the typer.Option default for *long_option* in *func_name* (ast.Constant defaults only)."""
|
||||
tree = ast.parse(source)
|
||||
for func_node in ast.walk(tree):
|
||||
if not isinstance(func_node, (ast.FunctionDef, ast.AsyncFunctionDef)):
|
||||
|
|
@ -39,7 +30,7 @@ def _find_typer_option_default(source: str, func_name: str, long_option: str):
|
|||
)
|
||||
if not is_typer_option:
|
||||
continue
|
||||
# First positional is the default; the rest are flags like "--host".
|
||||
# First positional is the default; the rest are flags.
|
||||
if not default.args:
|
||||
continue
|
||||
flags = [
|
||||
|
|
@ -56,7 +47,7 @@ def _find_typer_option_default(source: str, func_name: str, long_option: str):
|
|||
|
||||
|
||||
def test_studio_default_host_is_loopback():
|
||||
"""`unsloth studio` (studio_default) --host typer Option default must be 127.0.0.1."""
|
||||
"""`unsloth studio` (studio_default) --host default must be 127.0.0.1."""
|
||||
source = _STUDIO_CMD_PY.read_text()
|
||||
host_default = _find_typer_option_default(source, "studio_default", "--host")
|
||||
assert (
|
||||
|
|
@ -69,7 +60,7 @@ def test_studio_default_host_is_loopback():
|
|||
|
||||
|
||||
def test_studio_run_host_is_loopback():
|
||||
"""`unsloth studio run` --host typer Option default must be 127.0.0.1."""
|
||||
"""`unsloth studio run` --host default must be 127.0.0.1."""
|
||||
source = _STUDIO_CMD_PY.read_text()
|
||||
host_default = _find_typer_option_default(source, "run", "--host")
|
||||
assert host_default is not None, "Could not find --host typer.Option default in run()"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue