Skip to content

Commit

Permalink
drop python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed Feb 20, 2024
1 parent 41efa36 commit 2039bd7
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 100 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ 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']
include:
- {os: ubuntu-latest, pyv: 'pypy3.8'}
- {os: ubuntu-latest, pyv: 'pypy3.9'}
- {os: macos-14, pyv: '3.12'}

steps:
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ license = {text = "Apache-2.0"}
authors = [{ name = "Iterative", email = "support@dvc.org" }]
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Development Status :: 4 - Beta",
]
requires-python = ">=3.8"
requires-python = ">=3.9"
dynamic = ["version"]
dependencies = [
"funcy>=1.14; python_version < '3.12'",
Expand Down
13 changes: 5 additions & 8 deletions src/dvc_objects/db.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import itertools
import logging
from collections.abc import Iterable, Iterator
from contextlib import suppress
from functools import partial
from io import BytesIO
from typing import (
TYPE_CHECKING,
BinaryIO,
Callable,
Iterable,
Iterator,
List,
Optional,
Tuple,
Union,
cast,
)
Expand Down Expand Up @@ -139,9 +136,9 @@ def add_bytes(self, oid: str, data: Union[bytes, BinaryIO]) -> None:

def add(
self,
path: Union["AnyFSPath", List["AnyFSPath"]],
path: Union["AnyFSPath", list["AnyFSPath"]],
fs: "FileSystem",
oid: Union[str, List[str]],
oid: Union[str, list[str]],
hardlink: bool = False,
callback: "Callback" = DEFAULT_CALLBACK,
check_exists: bool = True,
Expand Down Expand Up @@ -206,7 +203,7 @@ def clear(self):
for oid in self.all():
self.delete(oid)

def _oid_parts(self, oid: str) -> Tuple[str, str]:
def _oid_parts(self, oid: str) -> tuple[str, str]:
return oid[:2], oid[2:]

def oid_to_path(self, oid) -> str:
Expand All @@ -218,7 +215,7 @@ def _list_prefixes(
jobs: Optional[int] = None,
) -> Iterator[str]:
if prefixes:
paths: Union[str, List[str]] = list(map(self.oid_to_path, prefixes))
paths: Union[str, list[str]] = list(map(self.oid_to_path, prefixes))
if len(paths) == 1:
paths = paths[0]
prefix = True
Expand Down
19 changes: 6 additions & 13 deletions src/dvc_objects/executors.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import asyncio
import queue
import sys
from collections.abc import Coroutine, Iterable, Iterator, Sequence
from concurrent import futures
from itertools import islice
from typing import (
Any,
Callable,
Coroutine,
Dict,
Iterable,
Iterator,
List,
Optional,
Sequence,
Set,
Tuple,
TypeVar,
)

Expand Down Expand Up @@ -50,7 +43,7 @@ def imap_unordered(
yield fn(*args)
return

def create_taskset(n: int) -> Set[futures.Future]:
def create_taskset(n: int) -> set[futures.Future]:
return {self.submit(fn, *args) for args in islice(it, n)}

tasks = create_taskset(self.max_workers * 5)
Expand Down Expand Up @@ -99,7 +92,7 @@ async def batch_coros( # noqa: C901
timeout: Optional[int] = None,
return_exceptions: bool = False,
nofiles: bool = False,
) -> List[Any]:
) -> list[Any]:
"""Run the given in coroutines in parallel.
The asyncio loop will be kept saturated with up to `batch_size` tasks in
Expand All @@ -116,12 +109,12 @@ async def batch_coros( # noqa: C901
batch_size = len(coros)
assert batch_size > 0

def create_taskset(n: int) -> Dict[asyncio.Task, int]:
def create_taskset(n: int) -> dict[asyncio.Task, int]:
return {asyncio.create_task(coro): i for i, coro in islice(it, n)}

it: Iterator[Tuple[int, Coroutine]] = enumerate(coros)
it: Iterator[tuple[int, Coroutine]] = enumerate(coros)
tasks = create_taskset(batch_size)
results: Dict[int, Any] = {}
results: dict[int, Any] = {}
while tasks:
done, pending = await asyncio.wait(
tasks.keys(), timeout=timeout, return_when=asyncio.FIRST_COMPLETED
Expand Down
6 changes: 3 additions & 3 deletions src/dvc_objects/fs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Mapping
from typing import TYPE_CHECKING, Iterator, Type
from collections.abc import Iterator, Mapping
from typing import TYPE_CHECKING
from urllib.parse import urlparse

from . import generic # noqa: F401
Expand Down Expand Up @@ -83,7 +83,7 @@ class Registry(Mapping):
def __init__(self, reg) -> None:
self._registry = reg

def __getitem__(self, key: str) -> Type["FileSystem"]:
def __getitem__(self, key: str) -> type["FileSystem"]:
entry = self._registry.get(key) or self._registry[Schemes.LOCAL]
try:
return _import_class(entry["class"])
Expand Down
Loading

0 comments on commit 2039bd7

Please sign in to comment.