mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
drop Python 3.8 support (#10265)
* drop Python 3.8 Note that this PR only makes typing related changes. Other changes can be done once this gets merged, they are relatively few in numbers. * bump build python version * add typing_extensions to lint group
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
import json
|
||||
import os
|
||||
from textwrap import dedent
|
||||
from typing import Dict, List
|
||||
|
||||
import pytest
|
||||
|
||||
from dvc import api
|
||||
|
||||
TRAIN_METRICS: List[Dict[str, Dict[str, float]]] = [
|
||||
TRAIN_METRICS: list[dict[str, dict[str, float]]] = [
|
||||
{
|
||||
"avg_prec": {"train": 0.85, "val": 0.75},
|
||||
"roc_auc": {"train": 0.80, "val": 0.70},
|
||||
@@ -17,7 +16,7 @@ TRAIN_METRICS: List[Dict[str, Dict[str, float]]] = [
|
||||
"roc_auc": {"train": 0.98, "val": 0.94},
|
||||
},
|
||||
]
|
||||
TEST_METRICS: List[Dict[str, Dict[str, float]]] = [
|
||||
TEST_METRICS: list[dict[str, dict[str, float]]] = [
|
||||
{"avg_prec": {"test": 0.72}, "roc_auc": {"test": 0.77}},
|
||||
{
|
||||
"avg_prec": {"test": 0.91},
|
||||
|
||||
@@ -4,11 +4,12 @@ import re
|
||||
import subprocess
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
from collections.abc import Iterator
|
||||
from contextlib import contextmanager, suppress
|
||||
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
||||
from pathlib import Path
|
||||
from threading import Thread
|
||||
from typing import ClassVar, Dict, Iterator
|
||||
from typing import ClassVar
|
||||
|
||||
import psutil
|
||||
import pytest
|
||||
@@ -42,7 +43,7 @@ UPDATER_INFO_STR = json.dumps(UPDATER_INFO).encode("utf8")
|
||||
def make_request_handler():
|
||||
class RequestHandler(SimpleHTTPRequestHandler):
|
||||
# save requests count for each method
|
||||
hits: ClassVar[Dict[str, int]] = defaultdict(int)
|
||||
hits: ClassVar[dict[str, int]] = defaultdict(int)
|
||||
|
||||
def log_message(self, format, *args) -> None: # noqa: A002
|
||||
super().log_message(format, *args)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -14,7 +13,7 @@ from dvc_data.hashfile.build import IgnoreInCollectedDirError
|
||||
from dvc_data.hashfile.utils import get_mtime_and_size
|
||||
|
||||
|
||||
def _to_pattern_info_list(str_list: List):
|
||||
def _to_pattern_info_list(str_list: list):
|
||||
return [PatternInfo(a, "") for a in str_list]
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import json
|
||||
import os
|
||||
from copy import deepcopy
|
||||
from typing import Dict, List
|
||||
from urllib.parse import urlparse
|
||||
from urllib.request import url2pathname
|
||||
|
||||
@@ -57,7 +56,7 @@ def extract_vega_specs(html_path, plots_ids):
|
||||
return result
|
||||
|
||||
|
||||
def drop_fields(datapoints: List[Dict], fields: List[str]):
|
||||
def drop_fields(datapoints: list[dict], fields: list[str]):
|
||||
tmp = deepcopy(datapoints)
|
||||
for datapoint in tmp:
|
||||
keys = set(datapoint.keys())
|
||||
@@ -192,7 +191,7 @@ def verify_vega_props(plot_id, json_result, title, x, y, **kwargs):
|
||||
assert plot_y == y
|
||||
|
||||
|
||||
def _update_datapoints(datapoints: List, update: Dict):
|
||||
def _update_datapoints(datapoints: list, update: dict):
|
||||
result = []
|
||||
for dp in datapoints:
|
||||
tmp = dp.copy()
|
||||
@@ -501,7 +500,7 @@ def test_repo_with_dvclive_plots(tmp_dir, capsys, repo_with_dvclive_plots):
|
||||
|
||||
for s in ("show", "diff"):
|
||||
_, json_result, split_json_result = call(capsys, subcommand=s)
|
||||
expected_result: Dict[str, Dict[str, list[str]]] = {
|
||||
expected_result: dict[str, dict[str, list[str]]] = {
|
||||
"data": {
|
||||
"dvclive/plots/metrics/metric.tsv": [],
|
||||
},
|
||||
|
||||
@@ -2,7 +2,6 @@ import logging
|
||||
import re
|
||||
from argparse import SUPPRESS, ArgumentParser
|
||||
from itertools import takewhile
|
||||
from typing import Tuple
|
||||
|
||||
import pytest
|
||||
import shtab
|
||||
@@ -12,10 +11,10 @@ from dvc.cli.parser import get_main_parser
|
||||
|
||||
|
||||
def command_tuples():
|
||||
root: Tuple[str, ...] = ()
|
||||
root: tuple[str, ...] = ()
|
||||
commands = [root]
|
||||
|
||||
def recurse_parser(parser: ArgumentParser, parents: Tuple[str, ...] = root) -> None:
|
||||
def recurse_parser(parser: ArgumentParser, parents: tuple[str, ...] = root) -> None:
|
||||
for positional in parser._get_positional_actions():
|
||||
if positional.help != SUPPRESS and isinstance(positional.choices, dict):
|
||||
public_cmds = shtab.get_public_subcommands(positional)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import datetime
|
||||
import random
|
||||
from typing import Dict, List
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -22,7 +21,7 @@ def test_collect_stable_sorting(dvc, scm, mocker):
|
||||
"7" * 40,
|
||||
]
|
||||
|
||||
def collect_queued_patched(_, baseline_revs) -> Dict[str, List["ExpRange"]]:
|
||||
def collect_queued_patched(_, baseline_revs) -> dict[str, list["ExpRange"]]:
|
||||
single_timestamp = datetime.datetime(2023, 6, 20, 0, 0, 0)
|
||||
|
||||
exp_ranges = [
|
||||
@@ -59,8 +58,8 @@ def test_collect_stable_sorting(dvc, scm, mocker):
|
||||
|
||||
|
||||
def _assert_experiment_rev_order(
|
||||
actual: List["ExpRange"],
|
||||
expected_revs: List[str],
|
||||
actual: list["ExpRange"],
|
||||
expected_revs: list[str],
|
||||
):
|
||||
expected_revs = expected_revs.copy()
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from typing import TYPE_CHECKING, Any, Dict
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from unittest.mock import ANY
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from unittest.mock import Mock
|
||||
|
||||
|
||||
def issubset(subset: Dict, superset: Dict) -> bool:
|
||||
def issubset(subset: dict, superset: dict) -> bool:
|
||||
assert superset == {**superset, **subset}
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user