Skip to content

Commit

Permalink
Improved typing (#1743)
Browse files Browse the repository at this point in the history
  • Loading branch information
NolanTrem authored Dec 31, 2024
1 parent a2108ef commit 39322c9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 29 deletions.
4 changes: 2 additions & 2 deletions py/cli/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from typing import Any, Dict
from typing import Any

import asyncclick as click
from rich.console import Console
Expand Down Expand Up @@ -73,7 +73,7 @@ def _ensure_config_dir_exists() -> None:
CONFIG_DIR.mkdir(parents=True, exist_ok=True)


def save_config(config_data: Dict[str, Any]) -> None:
def save_config(config_data: dict[str, Any]) -> None:
"""
Persist the given config data to ~/.r2r/config.json.
"""
Expand Down
25 changes: 0 additions & 25 deletions py/core/base/providers/ingestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,31 +131,6 @@ def get_default(cls, mode: str, app) -> "IngestionConfig":
else:
return cls(app=app)

@classmethod
def get_default(cls, mode: str, app) -> "IngestionConfig":
"""Return default ingestion configuration for a given mode."""
if mode == "hi-res":
# More thorough parsing, no skipping summaries, possibly larger `chunks_for_document_summary`.
return cls(app=app, parser_overrides={"pdf": "zerox"})
# elif mode == "fast":
# # Skip summaries and other enrichment steps for speed.
# return cls(
# app=app,
# )
else:
# For `custom` or any unrecognized mode, return a base config
return cls(app=app)

@classmethod
def set_default(cls, **kwargs):
for key, value in kwargs.items():
if key in cls._defaults:
cls._defaults[key] = value
else:
raise AttributeError(
f"No default attribute '{key}' in GenerationConfig"
)

class Config:
populate_by_name = True
json_schema_extra = {
Expand Down
4 changes: 2 additions & 2 deletions py/core/database/users.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from datetime import datetime
from typing import Any, Dict, List, Optional
from typing import Optional
from uuid import UUID

from fastapi import HTTPException
Expand Down Expand Up @@ -372,7 +372,7 @@ async def update_user_password(self, id: UUID, new_hashed_password: str):
query, [new_hashed_password, id]
)

async def get_all_users(self) -> List[User]:
async def get_all_users(self) -> list[User]:
"""Get all users with minimal information."""
query, params = (
QueryBuilder(self._get_table_name(self.TABLE_NAME))
Expand Down

0 comments on commit 39322c9

Please sign in to comment.