Skip to content

drop Python 3.8 support #10265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12

- run: python -m pip install --upgrade pip setuptools_scm build twine

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
pyv: ["3.8", "3.9", "3.10", "3.11", "3.12"]
pyv: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand Down
16 changes: 8 additions & 8 deletions dvc/annotations.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import asdict, dataclass, field, fields
from typing import Any, ClassVar, Dict, List, Optional
from typing import Any, ClassVar, Optional

from funcy import compact
from voluptuous import Required
Expand All @@ -14,10 +14,10 @@ class Annotation:

desc: Optional[str] = None
type: Optional[str] = None
labels: List[str] = field(default_factory=list)
meta: Dict[str, Any] = field(default_factory=dict)
labels: list[str] = field(default_factory=list)
meta: dict[str, Any] = field(default_factory=dict)

def to_dict(self) -> Dict[str, str]:
def to_dict(self) -> dict[str, str]:
return compact(asdict(self))


Expand All @@ -32,10 +32,10 @@ class Artifact:
path: str
desc: Optional[str] = None
type: Optional[str] = None
labels: List[str] = field(default_factory=list)
meta: Dict[str, Any] = field(default_factory=dict)
labels: list[str] = field(default_factory=list)
meta: dict[str, Any] = field(default_factory=dict)

def to_dict(self) -> Dict[str, str]:
def to_dict(self) -> dict[str, str]:
return compact(asdict(self))


Expand All @@ -46,7 +46,7 @@ def to_dict(self) -> Dict[str, str]:
Annotation.PARAM_LABELS: [str],
Annotation.PARAM_META: object,
}
ARTIFACT_SCHEMA: Dict[Any, Any] = {
ARTIFACT_SCHEMA: dict[Any, Any] = {
Required(Artifact.PARAM_PATH): str,
**ANNOTATION_SCHEMA, # type: ignore[arg-type]
}
6 changes: 3 additions & 3 deletions dvc/api/artifacts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, Optional
from typing import Any, Optional

from dvc.repo import Repo

Expand All @@ -8,7 +8,7 @@ def artifacts_show(
version: Optional[str] = None,
stage: Optional[str] = None,
repo: Optional[str] = None,
) -> Dict[str, str]:
) -> dict[str, str]:
"""
Return path and Git revision for an artifact in a DVC project.

Expand Down Expand Up @@ -36,7 +36,7 @@ def artifacts_show(
if version and stage:
raise ValueError("Artifact version and stage are mutually exclusive.")

repo_kwargs: Dict[str, Any] = {
repo_kwargs: dict[str, Any] = {
"subrepos": True,
"uninitialized": True,
}
Expand Down
10 changes: 5 additions & 5 deletions dvc/api/data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from contextlib import _GeneratorContextManager as GCM
from contextlib import contextmanager
from typing import Any, Dict, Optional
from typing import Any, Optional

from funcy import reraise

Expand Down Expand Up @@ -39,7 +39,7 @@ def get_url(path, repo=None, rev=None, remote=None):
from dvc.config import NoRemoteError
from dvc_data.index import StorageKeyError

repo_kwargs: Dict[str, Any] = {}
repo_kwargs: dict[str, Any] = {}
if remote:
repo_kwargs["config"] = {"core": {"remote": remote}}
with Repo.open(
Expand Down Expand Up @@ -74,8 +74,8 @@ def open( # noqa: A001
remote: Optional[str] = None,
mode: str = "r",
encoding: Optional[str] = None,
config: Optional[Dict[str, Any]] = None,
remote_config: Optional[Dict[str, Any]] = None,
config: Optional[dict[str, Any]] = None,
remote_config: Optional[dict[str, Any]] = None,
):
"""
Opens a file tracked in a DVC project.
Expand Down Expand Up @@ -233,7 +233,7 @@ def _open(
config=None,
remote_config=None,
):
repo_kwargs: Dict[str, Any] = {
repo_kwargs: dict[str, Any] = {
"subrepos": True,
"uninitialized": True,
"remote": remote,
Expand Down
10 changes: 5 additions & 5 deletions dvc/api/experiments.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, List, Optional, Union
from typing import Optional, Union

from rich.text import Text

Expand All @@ -9,7 +9,7 @@
def exp_save(
name: Optional[str] = None,
force: bool = False,
include_untracked: Optional[List[str]] = None,
include_untracked: Optional[list[str]] = None,
):
"""
Create a new DVC experiment using `exp save`.
Expand Down Expand Up @@ -61,12 +61,12 @@ def _postprocess(exp_rows):

def exp_show(
repo: Optional[str] = None,
revs: Optional[Union[str, List[str]]] = None,
revs: Optional[Union[str, list[str]]] = None,
num: int = 1,
param_deps: bool = False,
force: bool = False,
config: Optional[Dict] = None,
) -> List[Dict]:
config: Optional[dict] = None,
) -> list[dict]:
"""Get DVC experiments tracked in `repo`.

Without arguments, this function will retrieve all experiments derived from
Expand Down
8 changes: 4 additions & 4 deletions dvc/api/scm.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import List, Optional
from typing import Optional

from dvc.repo import Repo


def all_branches(repo: Optional[str] = None) -> List[str]:
def all_branches(repo: Optional[str] = None) -> list[str]:
"""Get all Git branches in a DVC repository.

Args:
Expand All @@ -20,7 +20,7 @@ def all_branches(repo: Optional[str] = None) -> List[str]:
return _repo.scm.list_branches()


def all_commits(repo: Optional[str] = None) -> List[str]:
def all_commits(repo: Optional[str] = None) -> list[str]:
"""Get all Git commits in a DVC repository.

Args:
Expand All @@ -37,7 +37,7 @@ def all_commits(repo: Optional[str] = None) -> List[str]:
return _repo.scm.list_all_commits()


def all_tags(repo: Optional[str] = None) -> List[str]:
def all_tags(repo: Optional[str] = None) -> list[str]:
"""Get all Git tags in a DVC repository.

Args:
Expand Down
13 changes: 7 additions & 6 deletions dvc/api/show.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import typing
from collections import Counter
from typing import Dict, Iterable, Optional, Union
from collections.abc import Iterable
from typing import Optional, Union

from funcy import first

from dvc.repo import Repo


def _postprocess(results):
processed: Dict[str, Dict] = {}
processed: dict[str, dict] = {}
for rev, rev_data in results.items():
if not rev_data:
continue
Expand Down Expand Up @@ -36,8 +37,8 @@ def metrics_show(
*targets: str,
repo: Optional[str] = None,
rev: Optional[str] = None,
config: Optional[Dict] = None,
) -> Dict:
config: Optional[dict] = None,
) -> dict:
"""Get metrics tracked in `repo`.

Without arguments, this function will retrieve all metrics from all tracked
Expand Down Expand Up @@ -159,8 +160,8 @@ def params_show(
stages: Optional[Union[str, Iterable[str]]] = None,
rev: Optional[str] = None,
deps: bool = False,
config: Optional[Dict] = None,
) -> Dict:
config: Optional[dict] = None,
) -> dict:
"""Get parameters tracked in `repo`.

Without arguments, this function will retrieve all params from all tracked
Expand Down
4 changes: 2 additions & 2 deletions dvc/cachemgr.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from typing import TYPE_CHECKING, Optional, Tuple
from typing import TYPE_CHECKING, Optional

from dvc.fs import GitFileSystem, Schemes
from dvc_data.hashfile.db import get_odb
Expand All @@ -15,7 +15,7 @@ def _get_odb(
repo,
settings,
fs=None,
prefix: Optional[Tuple[str, ...]] = None,
prefix: Optional[tuple[str, ...]] = None,
hash_name: Optional[str] = None,
**kwargs,
):
Expand Down
8 changes: 4 additions & 4 deletions dvc/commands/data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TYPE_CHECKING, ClassVar, Dict, Tuple
from typing import TYPE_CHECKING, ClassVar

from funcy import chunks, compact, log_durations

Expand All @@ -17,22 +17,22 @@


class CmdDataStatus(CmdBase):
COLORS: ClassVar[Dict[str, str]] = {
COLORS: ClassVar[dict[str, str]] = {
"not_in_remote": "red",
"not_in_cache": "red",
"committed": "green",
"uncommitted": "yellow",
"untracked": "cyan",
}
LABELS: ClassVar[Dict[str, str]] = {
LABELS: ClassVar[dict[str, str]] = {
"not_in_remote": "Not in remote",
"not_in_cache": "Not in cache",
"committed": "DVC committed changes",
"uncommitted": "DVC uncommitted changes",
"untracked": "Untracked files",
"unchanged": "DVC unchanged files",
}
HINTS: ClassVar[Dict[str, Tuple[str, ...]]] = {
HINTS: ClassVar[dict[str, tuple[str, ...]]] = {
"not_in_remote": ('use "dvc push <file>..." to upload files',),
"not_in_cache": ('use "dvc fetch <file>..." to download files',),
"committed": ("git commit the corresponding dvc files to update the repo",),
Expand Down
4 changes: 2 additions & 2 deletions dvc/commands/experiments/push.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict
from typing import Any

from dvc.cli import completion, formatter
from dvc.cli.command import CmdBase
Expand All @@ -11,7 +11,7 @@

class CmdExperimentsPush(CmdBase):
@staticmethod
def log_result(result: Dict[str, Any], remote: str):
def log_result(result: dict[str, Any], remote: str):
from dvc.utils import humanize

def join_exps(exps):
Expand Down
5 changes: 3 additions & 2 deletions dvc/commands/experiments/show.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import argparse
import re
from collections.abc import Iterable
from datetime import date, datetime
from typing import TYPE_CHECKING, Dict, Iterable
from typing import TYPE_CHECKING

from funcy import lmap

Expand Down Expand Up @@ -57,7 +58,7 @@ def baseline_styler(typ):

def show_experiments(
td: "TabularData",
headers: Dict[str, Iterable[str]],
headers: dict[str, Iterable[str]],
keep=None,
drop=None,
pager=True,
Expand Down
8 changes: 4 additions & 4 deletions dvc/commands/plots.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import argparse
import os
from typing import TYPE_CHECKING, Dict, List, Optional
from typing import TYPE_CHECKING, Optional

from funcy import compact, first, get_in

Expand All @@ -20,14 +20,14 @@


def _show_json(
renderers_with_errors: List["RendererWithErrors"],
renderers_with_errors: list["RendererWithErrors"],
split=False,
errors: Optional[Dict[str, Exception]] = None,
errors: Optional[dict[str, Exception]] = None,
):
from dvc.render.convert import to_json
from dvc.utils.serialize import encode_exception

all_errors: List[Dict] = []
all_errors: list[dict] = []
data = {}

for renderer, src_errors, def_errors in renderers_with_errors:
Expand Down
11 changes: 6 additions & 5 deletions dvc/commands/stage.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import argparse
import logging
from collections.abc import Iterable
from contextlib import contextmanager
from itertools import chain, filterfalse
from typing import TYPE_CHECKING, Dict, Iterable, List
from typing import TYPE_CHECKING

from dvc.cli import completion, formatter
from dvc.cli.command import CmdBase
Expand Down Expand Up @@ -33,7 +34,7 @@ def part_desc(outs: Iterable["Output"]) -> str:
def is_plot_or_metric(out: "Output"):
return bool(out.plot) or bool(out.metric)

desc: List[str] = []
desc: list[str] = []

outs = list(filterfalse(is_plot_or_metric, stage.outs))
if outs:
Expand All @@ -55,7 +56,7 @@ def prepare_stages_data(
stages: Iterable["Stage"],
description: bool = True,
max_length: int = MAX_TEXT_LENGTH,
) -> Dict[str, str]:
) -> dict[str, str]:
return {
stage.addressing: (
prepare_description(stage, max_length=max_length) if description else ""
Expand All @@ -67,7 +68,7 @@ def prepare_stages_data(
class CmdStageList(CmdBase):
def _get_stages(self) -> Iterable["Stage"]:
if self.args.all:
stages: List["Stage"] = self.repo.index.stages
stages: list["Stage"] = self.repo.index.stages
logger.trace("%d no. of stages found", len(stages))
return stages

Expand Down Expand Up @@ -96,7 +97,7 @@ def log_error(relpath: str, exc: Exception):
return 0


def parse_cmd(commands: List[str]) -> str:
def parse_cmd(commands: list[str]) -> str:
"""
We need to take into account two cases:

Expand Down
Loading