Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ exclude = [
# All files now have type annotations! 🎉
#
# ============================================================================
# Section 2: Files that need strict typing issues fixed (131 files)
# Section 2: Files that need strict typing issues fixed (123 files)
# ============================================================================
# These files have some type hints but fail strict type checking due to
# incomplete annotations, Any usage, or other strict mode violations.
Expand All @@ -395,15 +395,6 @@ exclude = [
"^src/llama_stack/core/testing_context\\.py$",
"^src/llama_stack/core/utils/exec\\.py$",
"^src/llama_stack/core/utils/serialize\\.py$",
# CLI files (8 files)
"^src/llama_stack/cli/stack/_list_deps\\.py$",
"^src/llama_stack/cli/stack/list_apis\\.py$",
"^src/llama_stack/cli/stack/list_deps\\.py$",
"^src/llama_stack/cli/stack/list_providers\\.py$",
"^src/llama_stack/cli/stack/run\\.py$",
"^src/llama_stack/cli/stack/utils\\.py$",
"^src/llama_stack/cli/subcommand\\.py$",
"^src/llama_stack/cli/utils\\.py$",
# Providers - Inline (27 files)
"^src/llama_stack/providers/inline/batches/reference/__init__\\.py$",
"^src/llama_stack/providers/inline/batches/reference/batches\\.py$",
Expand Down
4 changes: 2 additions & 2 deletions src/llama_stack/cli/llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def __init__(self) -> None:
subparsers = self.parser.add_subparsers(title="subcommands")

# Add sub-commands
StackParser.create(subparsers) # type: ignore[no-untyped-call]
StackParser.create(subparsers)

print_subcommand_description(self.parser, subparsers) # type: ignore[no-untyped-call]
print_subcommand_description(self.parser, subparsers)

def parse_args(self) -> argparse.Namespace:
args = self.parser.parse_args()
Expand Down
4 changes: 2 additions & 2 deletions src/llama_stack/cli/stack/_list_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def run_stack_list_deps_command(args: argparse.Namespace) -> None:
print(output)


def quote_if_needed(dep):
def quote_if_needed(dep: str) -> str:
"""Wrap a dependency string in quotes if it contains shell-special characters.

Args:
Expand All @@ -160,7 +160,7 @@ def quote_if_needed(dep):
return f"'{dep}'" if needs_quoting else dep


def quote_special_dep(dep_string):
def quote_special_dep(dep_string: str) -> str:
"""
Quote individual packages in a special dependency string.
Special deps may contain multiple packages and flags like --extra-index-url.
Expand Down
4 changes: 2 additions & 2 deletions src/llama_stack/cli/stack/list_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class StackListApis(Subcommand):
"""CLI subcommand to list all APIs in the Llama Stack implementation."""

def __init__(self, subparsers: argparse._SubParsersAction):
def __init__(self, subparsers: argparse._SubParsersAction) -> None:
super().__init__()
self.parser = subparsers.add_parser(
"list-apis",
Expand All @@ -23,7 +23,7 @@ def __init__(self, subparsers: argparse._SubParsersAction):
self._add_arguments()
self.parser.set_defaults(func=self._run_apis_list_cmd)

def _add_arguments(self):
def _add_arguments(self) -> None:
pass

def _run_apis_list_cmd(self, args: argparse.Namespace) -> None:
Expand Down
4 changes: 2 additions & 2 deletions src/llama_stack/cli/stack/list_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class StackListDeps(Subcommand):
"""CLI subcommand to list pip dependencies for a Llama Stack distribution."""

def __init__(self, subparsers: argparse._SubParsersAction):
def __init__(self, subparsers: argparse._SubParsersAction) -> None:
super().__init__()
self.parser = subparsers.add_parser(
"list-deps",
Expand All @@ -22,7 +22,7 @@ def __init__(self, subparsers: argparse._SubParsersAction):
self._add_arguments()
self.parser.set_defaults(func=self._run_stack_list_deps_command)

def _add_arguments(self):
def _add_arguments(self) -> None:
self.parser.add_argument(
"config",
type=str,
Expand Down
6 changes: 3 additions & 3 deletions src/llama_stack/cli/stack/list_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class StackListProviders(Subcommand):
"""CLI subcommand to list available providers for Llama Stack APIs."""

def __init__(self, subparsers: argparse._SubParsersAction):
def __init__(self, subparsers: argparse._SubParsersAction) -> None:
super().__init__()
self.parser = subparsers.add_parser(
"list-providers",
Expand All @@ -24,12 +24,12 @@ def __init__(self, subparsers: argparse._SubParsersAction):
self.parser.set_defaults(func=self._run_providers_list_cmd)

@property
def providable_apis(self):
def providable_apis(self) -> list[str]:
from llama_stack.core.distribution import providable_apis

return [api.value for api in providable_apis()]

def _add_arguments(self):
def _add_arguments(self) -> None:
self.parser.add_argument(
"api",
type=str,
Expand Down
6 changes: 3 additions & 3 deletions src/llama_stack/cli/stack/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
class StackRun(Subcommand):
"""CLI subcommand to start a Llama Stack distribution server."""

def __init__(self, subparsers: argparse._SubParsersAction):
def __init__(self, subparsers: argparse._SubParsersAction) -> None:
super().__init__()
self.parser = subparsers.add_parser(
"run",
Expand All @@ -41,7 +41,7 @@ def __init__(self, subparsers: argparse._SubParsersAction):
self._add_arguments()
self.parser.set_defaults(func=self._run_stack_run_cmd)

def _add_arguments(self):
def _add_arguments(self) -> None:
self.parser.add_argument(
"config",
type=str,
Expand Down Expand Up @@ -195,7 +195,7 @@ def _uvicorn_run(self, config_file: Path | None, args: argparse.Namespace) -> No
except (KeyboardInterrupt, SystemExit):
logger.info("Received interrupt signal, shutting down gracefully...")

def _start_ui_development_server(self, stack_server_port: int):
def _start_ui_development_server(self, stack_server_port: int) -> None:
logger.info("Attempting to start UI development server...")
# Check if npm is available
npm_check = subprocess.run(["npm", "--version"], capture_output=True, text=True, check=False)
Expand Down
6 changes: 5 additions & 1 deletion src/llama_stack/cli/stack/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.

from __future__ import annotations

import argparse
from enum import Enum
from pathlib import Path
from typing import Any

from llama_stack.core.datatypes import Provider, ProviderSpec
from llama_stack.core.utils.dynamic import instantiate_class_type
Expand All @@ -21,7 +25,7 @@ class ImageType(Enum):
VENV = "venv"


def print_subcommand_description(parser, subparsers):
def print_subcommand_description(parser: argparse.ArgumentParser, subparsers: argparse._SubParsersAction[Any]) -> None:
"""Print descriptions of subcommands."""
description_text = ""
for name, subcommand in subparsers.choices.items():
Expand Down
8 changes: 5 additions & 3 deletions src/llama_stack/cli/subcommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.

from typing import Any


class Subcommand:
"""All llama cli subcommands must inherit from this class"""

def __init__(self, *args, **kwargs):
def __init__(self, *args: Any, **kwargs: Any) -> None:
pass

@classmethod
def create(cls, *args, **kwargs):
def create(cls, *args: Any, **kwargs: Any) -> "Subcommand":
return cls(*args, **kwargs)

def _add_arguments(self):
def _add_arguments(self) -> None:
pass
2 changes: 1 addition & 1 deletion src/llama_stack/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


# TODO: this can probably just be inlined now?
def add_config_distro_args(parser: argparse.ArgumentParser):
def add_config_distro_args(parser: argparse.ArgumentParser) -> None:
"""Add unified config/distro arguments."""
group = parser.add_mutually_exclusive_group(required=True)

Expand Down
Loading