Skip to content

Commit b647475

Browse files
authored
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
1 parent 966adec commit b647475

File tree

126 files changed

+843
-905
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+843
-905
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
- uses: actions/setup-python@v5
2727
with:
28-
python-version: 3.8
28+
python-version: 3.12
2929

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

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
fail-fast: false
2424
matrix:
2525
os: [ubuntu-20.04, windows-latest, macos-latest]
26-
pyv: ["3.8", "3.9", "3.10", "3.11", "3.12"]
26+
pyv: ["3.9", "3.10", "3.11", "3.12"]
2727

2828
steps:
2929
- uses: actions/checkout@v4

dvc/annotations.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from dataclasses import asdict, dataclass, field, fields
2-
from typing import Any, ClassVar, Dict, List, Optional
2+
from typing import Any, ClassVar, Optional
33

44
from funcy import compact
55
from voluptuous import Required
@@ -14,10 +14,10 @@ class Annotation:
1414

1515
desc: Optional[str] = None
1616
type: Optional[str] = None
17-
labels: List[str] = field(default_factory=list)
18-
meta: Dict[str, Any] = field(default_factory=dict)
17+
labels: list[str] = field(default_factory=list)
18+
meta: dict[str, Any] = field(default_factory=dict)
1919

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

2323

@@ -32,10 +32,10 @@ class Artifact:
3232
path: str
3333
desc: Optional[str] = None
3434
type: Optional[str] = None
35-
labels: List[str] = field(default_factory=list)
36-
meta: Dict[str, Any] = field(default_factory=dict)
35+
labels: list[str] = field(default_factory=list)
36+
meta: dict[str, Any] = field(default_factory=dict)
3737

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

4141

@@ -46,7 +46,7 @@ def to_dict(self) -> Dict[str, str]:
4646
Annotation.PARAM_LABELS: [str],
4747
Annotation.PARAM_META: object,
4848
}
49-
ARTIFACT_SCHEMA: Dict[Any, Any] = {
49+
ARTIFACT_SCHEMA: dict[Any, Any] = {
5050
Required(Artifact.PARAM_PATH): str,
5151
**ANNOTATION_SCHEMA, # type: ignore[arg-type]
5252
}

dvc/api/artifacts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, Optional
1+
from typing import Any, Optional
22

33
from dvc.repo import Repo
44

@@ -8,7 +8,7 @@ def artifacts_show(
88
version: Optional[str] = None,
99
stage: Optional[str] = None,
1010
repo: Optional[str] = None,
11-
) -> Dict[str, str]:
11+
) -> dict[str, str]:
1212
"""
1313
Return path and Git revision for an artifact in a DVC project.
1414
@@ -36,7 +36,7 @@ def artifacts_show(
3636
if version and stage:
3737
raise ValueError("Artifact version and stage are mutually exclusive.")
3838

39-
repo_kwargs: Dict[str, Any] = {
39+
repo_kwargs: dict[str, Any] = {
4040
"subrepos": True,
4141
"uninitialized": True,
4242
}

dvc/api/data.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from contextlib import _GeneratorContextManager as GCM
22
from contextlib import contextmanager
3-
from typing import Any, Dict, Optional
3+
from typing import Any, Optional
44

55
from funcy import reraise
66

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

42-
repo_kwargs: Dict[str, Any] = {}
42+
repo_kwargs: dict[str, Any] = {}
4343
if remote:
4444
repo_kwargs["config"] = {"core": {"remote": remote}}
4545
with Repo.open(
@@ -74,8 +74,8 @@ def open( # noqa: A001
7474
remote: Optional[str] = None,
7575
mode: str = "r",
7676
encoding: Optional[str] = None,
77-
config: Optional[Dict[str, Any]] = None,
78-
remote_config: Optional[Dict[str, Any]] = None,
77+
config: Optional[dict[str, Any]] = None,
78+
remote_config: Optional[dict[str, Any]] = None,
7979
):
8080
"""
8181
Opens a file tracked in a DVC project.
@@ -233,7 +233,7 @@ def _open(
233233
config=None,
234234
remote_config=None,
235235
):
236-
repo_kwargs: Dict[str, Any] = {
236+
repo_kwargs: dict[str, Any] = {
237237
"subrepos": True,
238238
"uninitialized": True,
239239
"remote": remote,

dvc/api/experiments.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Dict, List, Optional, Union
1+
from typing import Optional, Union
22

33
from rich.text import Text
44

@@ -9,7 +9,7 @@
99
def exp_save(
1010
name: Optional[str] = None,
1111
force: bool = False,
12-
include_untracked: Optional[List[str]] = None,
12+
include_untracked: Optional[list[str]] = None,
1313
):
1414
"""
1515
Create a new DVC experiment using `exp save`.
@@ -61,12 +61,12 @@ def _postprocess(exp_rows):
6161

6262
def exp_show(
6363
repo: Optional[str] = None,
64-
revs: Optional[Union[str, List[str]]] = None,
64+
revs: Optional[Union[str, list[str]]] = None,
6565
num: int = 1,
6666
param_deps: bool = False,
6767
force: bool = False,
68-
config: Optional[Dict] = None,
69-
) -> List[Dict]:
68+
config: Optional[dict] = None,
69+
) -> list[dict]:
7070
"""Get DVC experiments tracked in `repo`.
7171
7272
Without arguments, this function will retrieve all experiments derived from

dvc/api/scm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from typing import List, Optional
1+
from typing import Optional
22

33
from dvc.repo import Repo
44

55

6-
def all_branches(repo: Optional[str] = None) -> List[str]:
6+
def all_branches(repo: Optional[str] = None) -> list[str]:
77
"""Get all Git branches in a DVC repository.
88
99
Args:
@@ -20,7 +20,7 @@ def all_branches(repo: Optional[str] = None) -> List[str]:
2020
return _repo.scm.list_branches()
2121

2222

23-
def all_commits(repo: Optional[str] = None) -> List[str]:
23+
def all_commits(repo: Optional[str] = None) -> list[str]:
2424
"""Get all Git commits in a DVC repository.
2525
2626
Args:
@@ -37,7 +37,7 @@ def all_commits(repo: Optional[str] = None) -> List[str]:
3737
return _repo.scm.list_all_commits()
3838

3939

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

dvc/api/show.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import typing
22
from collections import Counter
3-
from typing import Dict, Iterable, Optional, Union
3+
from collections.abc import Iterable
4+
from typing import Optional, Union
45

56
from funcy import first
67

78
from dvc.repo import Repo
89

910

1011
def _postprocess(results):
11-
processed: Dict[str, Dict] = {}
12+
processed: dict[str, dict] = {}
1213
for rev, rev_data in results.items():
1314
if not rev_data:
1415
continue
@@ -36,8 +37,8 @@ def metrics_show(
3637
*targets: str,
3738
repo: Optional[str] = None,
3839
rev: Optional[str] = None,
39-
config: Optional[Dict] = None,
40-
) -> Dict:
40+
config: Optional[dict] = None,
41+
) -> dict:
4142
"""Get metrics tracked in `repo`.
4243
4344
Without arguments, this function will retrieve all metrics from all tracked
@@ -159,8 +160,8 @@ def params_show(
159160
stages: Optional[Union[str, Iterable[str]]] = None,
160161
rev: Optional[str] = None,
161162
deps: bool = False,
162-
config: Optional[Dict] = None,
163-
) -> Dict:
163+
config: Optional[dict] = None,
164+
) -> dict:
164165
"""Get parameters tracked in `repo`.
165166
166167
Without arguments, this function will retrieve all params from all tracked

dvc/cachemgr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
from typing import TYPE_CHECKING, Optional, Tuple
2+
from typing import TYPE_CHECKING, Optional
33

44
from dvc.fs import GitFileSystem, Schemes
55
from dvc_data.hashfile.db import get_odb
@@ -15,7 +15,7 @@ def _get_odb(
1515
repo,
1616
settings,
1717
fs=None,
18-
prefix: Optional[Tuple[str, ...]] = None,
18+
prefix: Optional[tuple[str, ...]] = None,
1919
hash_name: Optional[str] = None,
2020
**kwargs,
2121
):

dvc/commands/data.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import TYPE_CHECKING, ClassVar, Dict, Tuple
1+
from typing import TYPE_CHECKING, ClassVar
22

33
from funcy import chunks, compact, log_durations
44

@@ -17,22 +17,22 @@
1717

1818

1919
class CmdDataStatus(CmdBase):
20-
COLORS: ClassVar[Dict[str, str]] = {
20+
COLORS: ClassVar[dict[str, str]] = {
2121
"not_in_remote": "red",
2222
"not_in_cache": "red",
2323
"committed": "green",
2424
"uncommitted": "yellow",
2525
"untracked": "cyan",
2626
}
27-
LABELS: ClassVar[Dict[str, str]] = {
27+
LABELS: ClassVar[dict[str, str]] = {
2828
"not_in_remote": "Not in remote",
2929
"not_in_cache": "Not in cache",
3030
"committed": "DVC committed changes",
3131
"uncommitted": "DVC uncommitted changes",
3232
"untracked": "Untracked files",
3333
"unchanged": "DVC unchanged files",
3434
}
35-
HINTS: ClassVar[Dict[str, Tuple[str, ...]]] = {
35+
HINTS: ClassVar[dict[str, tuple[str, ...]]] = {
3636
"not_in_remote": ('use "dvc push <file>..." to upload files',),
3737
"not_in_cache": ('use "dvc fetch <file>..." to download files',),
3838
"committed": ("git commit the corresponding dvc files to update the repo",),

0 commit comments

Comments
 (0)