convert-*.py: import cast from typing and other refactor
This commit is contained in:
parent
04c4fffdcc
commit
f2b425c59c
1 changed files with 5 additions and 5 deletions
|
@ -4,7 +4,7 @@ import re
|
|||
import json
|
||||
import frontmatter
|
||||
from pathlib import Path
|
||||
from typing import Any, Optional
|
||||
from typing import Any, Optional, cast
|
||||
from dataclasses import dataclass
|
||||
|
||||
from .constants import Keys
|
||||
|
@ -105,7 +105,7 @@ class Metadata:
|
|||
return json.load(f)
|
||||
|
||||
@staticmethod
|
||||
def load_model_card(model_path: Optional[Path] = None) -> dict[str, object]:
|
||||
def load_model_card(model_path: Optional[Path] = None) -> dict[str, Any]:
|
||||
if model_path is None or not model_path.exists():
|
||||
return {}
|
||||
|
||||
|
@ -115,10 +115,10 @@ class Metadata:
|
|||
return {}
|
||||
|
||||
with open(model_card_path, "r", encoding="utf-8") as f:
|
||||
return cast("dict[str, object]", frontmatter.load(f))
|
||||
return cast("dict[str, Any]", frontmatter.load(f))
|
||||
|
||||
@staticmethod
|
||||
def load_hf_parameters(model_path: Optional[Path] = None) -> dict[str, object]:
|
||||
def load_hf_parameters(model_path: Optional[Path] = None) -> dict[str, Any]:
|
||||
if model_path is None or not model_path.exists():
|
||||
return {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue