Move to ruff for the linter

This commit is contained in:
Ashwin Bharambe 2025-01-31 22:25:10 -08:00
parent 6249d26611
commit e67beafef7
3 changed files with 36 additions and 25 deletions

View file

@ -5,10 +5,8 @@ default_language_version:
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: 6306a48f7dae5861702d573c9c247e4e9498e867 rev: v5.0.0 # Latest stable version
hooks: hooks:
- id: trailing-whitespace
- id: check-ast
- id: check-merge-conflict - id: check-merge-conflict
- id: check-added-large-files - id: check-added-large-files
args: ['--maxkb=1000'] args: ['--maxkb=1000']
@ -28,23 +26,32 @@ repos:
- --license-filepath - --license-filepath
- docs/license_header.txt - docs/license_header.txt
- repo: https://github.com/pycqa/flake8 - repo: https://github.com/astral-sh/ruff-pre-commit
rev: 34cbf8ef3950f43d09b85e2e45c15ae5717dc37b rev: v0.9.4
hooks: hooks:
- id: flake8 - id: ruff
additional_dependencies: args: [
- flake8-bugbear == 22.4.25 --fix,
- pep8-naming == 0.12.1 --exit-non-zero-on-fix
- torchfix ]
args: ['--config=.flake8'] - id: ruff-format
- repo: https://github.com/omnilib/ufmt - repo: https://github.com/adamchainz/blacken-docs
rev: v2.7.0 rev: 1.19.0
hooks: hooks:
- id: ufmt - id: blacken-docs
additional_dependencies: additional_dependencies:
- black == 24.4.2 - black==24.3.0
- usort == 1.0.8
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.14.0
# hooks:
# - id: mypy
# additional_dependencies:
# - types-requests
# - types-setuptools
# - pydantic
# args: [--ignore-missing-imports]
# - repo: https://github.com/jsh9/pydoclint # - repo: https://github.com/jsh9/pydoclint
# rev: d88180a8632bb1602a4d81344085cf320f288c5a # rev: d88180a8632bb1602a4d81344085cf320f288c5a
@ -71,3 +78,7 @@ repos:
# require_serial: true # require_serial: true
# files: ^llama_stack/templates/.*$ # files: ^llama_stack/templates/.*$
# stages: [manual] # stages: [manual]
ci:
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate

View file

@ -68,9 +68,9 @@ def create_api_client_class(protocol) -> Type:
return_type = None return_type = None
else: else:
return_type = extract_non_async_iterator_type(sig.return_annotation) return_type = extract_non_async_iterator_type(sig.return_annotation)
assert ( assert return_type, (
return_type f"Could not extract return type for {sig.return_annotation}"
), f"Could not extract return type for {sig.return_annotation}" )
async with httpx.AsyncClient() as client: async with httpx.AsyncClient() as client:
params = self.httpx_request_params(method_name, *args, **kwargs) params = self.httpx_request_params(method_name, *args, **kwargs)
@ -87,9 +87,9 @@ def create_api_client_class(protocol) -> Type:
webmethod, sig = self.routes[method_name] webmethod, sig = self.routes[method_name]
return_type = extract_async_iterator_type(sig.return_annotation) return_type = extract_async_iterator_type(sig.return_annotation)
assert ( assert return_type, (
return_type f"Could not extract return type for {sig.return_annotation}"
), f"Could not extract return type for {sig.return_annotation}" )
async with httpx.AsyncClient() as client: async with httpx.AsyncClient() as client:
params = self.httpx_request_params(method_name, *args, **kwargs) params = self.httpx_request_params(method_name, *args, **kwargs)

View file

@ -58,9 +58,9 @@ class RunConfigSettings(BaseModel):
) )
config_class = provider_registry[api][provider_type].config_class config_class = provider_registry[api][provider_type].config_class
assert ( assert config_class is not None, (
config_class is not None f"No config class for provider type: {provider_type} for API: {api_str}"
), f"No config class for provider type: {provider_type} for API: {api_str}" )
config_class = instantiate_class_type(config_class) config_class = instantiate_class_type(config_class)
if hasattr(config_class, "sample_run_config"): if hasattr(config_class, "sample_run_config"):