No more Tuple, List, Dict (#38797)
* No more Tuple, List, Dict * make fixup * More style fixes * Docstring fixes with regex replacement * Trigger tests * Redo fixes after rebase * Fix copies * [test all] * update * [test all] * update * [test all] * make style after rebase * Patch the hf_argparser test * Patch the hf_argparser test * style fixes * style fixes * style fixes * Fix docstrings in Cohere test * [test all] --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
@@ -21,7 +21,7 @@ import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import requests
|
||||
from get_ci_error_statistics import get_jobs
|
||||
@@ -109,7 +109,7 @@ def handle_stacktraces(test_results):
|
||||
return stacktraces
|
||||
|
||||
|
||||
def dicts_to_sum(objects: Union[Dict[str, Dict], List[dict]]):
|
||||
def dicts_to_sum(objects: Union[dict[str, dict], list[dict]]):
|
||||
if isinstance(objects, dict):
|
||||
lists = objects.values()
|
||||
else:
|
||||
@@ -126,9 +126,9 @@ class Message:
|
||||
self,
|
||||
title: str,
|
||||
ci_title: str,
|
||||
model_results: Dict,
|
||||
additional_results: Dict,
|
||||
selected_warnings: Optional[List] = None,
|
||||
model_results: dict,
|
||||
additional_results: dict,
|
||||
selected_warnings: Optional[list] = None,
|
||||
prev_ci_artifacts=None,
|
||||
other_ci_artifacts=None,
|
||||
):
|
||||
@@ -203,15 +203,15 @@ class Message:
|
||||
return f"{int(hours)}h{int(minutes)}m{int(seconds)}s"
|
||||
|
||||
@property
|
||||
def header(self) -> Dict:
|
||||
def header(self) -> dict:
|
||||
return {"type": "header", "text": {"type": "plain_text", "text": self.title}}
|
||||
|
||||
@property
|
||||
def ci_title_section(self) -> Dict:
|
||||
def ci_title_section(self) -> dict:
|
||||
return {"type": "section", "text": {"type": "mrkdwn", "text": self.ci_title}}
|
||||
|
||||
@property
|
||||
def no_failures(self) -> Dict:
|
||||
def no_failures(self) -> dict:
|
||||
return {
|
||||
"type": "section",
|
||||
"text": {
|
||||
@@ -227,7 +227,7 @@ class Message:
|
||||
}
|
||||
|
||||
@property
|
||||
def failures(self) -> Dict:
|
||||
def failures(self) -> dict:
|
||||
return {
|
||||
"type": "section",
|
||||
"text": {
|
||||
@@ -246,7 +246,7 @@ class Message:
|
||||
}
|
||||
|
||||
@property
|
||||
def warnings(self) -> Dict:
|
||||
def warnings(self) -> dict:
|
||||
# If something goes wrong, let's avoid the CI report failing to be sent.
|
||||
button_text = "Check warnings (Link not found)"
|
||||
# Use the workflow run link
|
||||
@@ -287,7 +287,7 @@ class Message:
|
||||
return f"{'0'.rjust(rjust)} | {str(report['multi']).rjust(rjust)} | "
|
||||
|
||||
@property
|
||||
def category_failures(self) -> Dict:
|
||||
def category_failures(self) -> dict:
|
||||
if job_name != "run_models_gpu":
|
||||
category_failures_report = ""
|
||||
return {"type": "section", "text": {"type": "mrkdwn", "text": category_failures_report}}
|
||||
@@ -360,7 +360,7 @@ class Message:
|
||||
return entries_changed
|
||||
|
||||
@property
|
||||
def model_failures(self) -> List[Dict]:
|
||||
def model_failures(self) -> list[dict]:
|
||||
# Obtain per-model failures
|
||||
def per_model_sum(model_category_dict):
|
||||
return dicts_to_sum(model_category_dict["failed"].values())
|
||||
@@ -523,7 +523,7 @@ class Message:
|
||||
return model_failure_sections
|
||||
|
||||
@property
|
||||
def additional_failures(self) -> Dict:
|
||||
def additional_failures(self) -> dict:
|
||||
failures = {k: v["failed"] for k, v in self.additional_results.items()}
|
||||
errors = {k: v["error"] for k, v in self.additional_results.items()}
|
||||
|
||||
@@ -953,7 +953,7 @@ def retrieve_available_artifacts():
|
||||
def add_path(self, path: str, gpu: Optional[str] = None):
|
||||
self.paths.append({"name": self.name, "path": path, "gpu": gpu})
|
||||
|
||||
_available_artifacts: Dict[str, Artifact] = {}
|
||||
_available_artifacts: dict[str, Artifact] = {}
|
||||
|
||||
directories = filter(os.path.isdir, os.listdir())
|
||||
for directory in directories:
|
||||
|
||||
Reference in New Issue
Block a user