Skip to content

Commit

Permalink
dvc: drop python 3.7
Browse files Browse the repository at this point in the history
Also upgraded with `pyupgrade --py38-plus`

Fixes iterative#7708
  • Loading branch information
efiop committed May 30, 2022
1 parent 34ef180 commit 844f77b
Show file tree
Hide file tree
Showing 19 changed files with 22 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmarks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
access_token: ${{ github.token }}
- uses: actions/setup-python@v3
with:
python-version: 3.7
python-version: 3.8
- uses: iterative/dvc-bench@main
with:
pytest_options: "-k 'test_init or test_help'"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.7
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.7
python-version: 3.8
- name: Install
run: pip install ".[all,tests]"
- name: Build packages
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
pyv: ["3.7", "3.8", "3.9", "3.10"]
pyv: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion dvc/commands/experiments/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _post_init_display(
) -> None:
from dvc.utils import humanize

path_fmt = "[green]{0}[/green]".format
path_fmt = "[green]{}[/green]".format
if new_deps:
deps_paths = humanize.join(map(path_fmt, new_deps))
ui.write(f"Creating dependencies: {deps_paths}", styled=True)
Expand Down
7 changes: 1 addition & 6 deletions dvc/info.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import importlib.metadata as importlib_metadata
import itertools
import os
import pathlib
Expand All @@ -13,12 +14,6 @@
from dvc.utils import error_link
from dvc.utils.pkg import PKG

try:
import importlib.metadata as importlib_metadata
except ImportError: # < 3.8
import importlib_metadata # type: ignore[no-redef]


package = "" if PKG is None else f"({PKG})"


Expand Down
3 changes: 1 addition & 2 deletions dvc/proc/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ def __init__(self, wdir: Optional[str] = None):
def __iter__(self) -> Generator[str, None, None]:
if not os.path.exists(self.wdir):
return
for name in os.listdir(self.wdir):
yield name
yield from os.listdir(self.wdir)

def __getitem__(self, key: str) -> "ProcessInfo":
info_path = os.path.join(self.wdir, key, f"{key}.json")
Expand Down
1 change: 0 additions & 1 deletion dvc/testing/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def make(
# connection resulting in PermissionErrors in Windows.
ignore = ignore_patterns("cache.db*")
for entry in os.listdir(cache):
# shutil.copytree's dirs_exist_ok is only available in >=3.8
_fs_copy(
os.path.join(cache, entry),
os.path.join(path, entry),
Expand Down
2 changes: 1 addition & 1 deletion dvc/utils/strictyaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def __init__(
self.path = path or ""

message = f"'{rel}' validation failed"
message += " in revision '{}'".format(rev[:7]) if rev else ""
message += f" in revision '{rev[:7]}'" if rev else ""
if len(self.exc.errors) > 1:
message += f": {len(self.exc.errors)} errors"
super().__init__(f"{message}")
Expand Down
4 changes: 1 addition & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ keywords = data-science, data-version-control, machine-learning, git
classifiers =
Development Status :: 4 - Beta
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Expand All @@ -30,7 +29,7 @@ setup_requires =
setuptools_scm[toml]>=6.3.1
setuptools_scm_git_archive==1.1

python_requires = >=3.7
python_requires = >=3.8
zip_safe = False
packages = find:
include_package_data = True
Expand All @@ -55,7 +54,6 @@ install_requires =
networkx>=2.5
psutil>=5.8.0
pydot>=1.2.4
importlib-metadata>=1.4; python_version < '3.8'
importlib-resources>=5.2.2; python_version < '3.9'
flatten_dict>=0.4.1,<1
tabulate>=0.8.7
Expand Down
4 changes: 2 additions & 2 deletions tests/dir_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ def __init__(self, tmp_dir, name, url):
@pytest.fixture
def git_upstream(tmp_dir, erepo_dir, git_dir, request):
remote = erepo_dir if "dvc" in request.fixturenames else git_dir
url = "file://{}".format(remote.resolve().as_posix())
url = f"file://{remote.resolve().as_posix()}"
tmp_dir.scm.gitpython.repo.create_remote("upstream", url)
return GitRemote(remote, "upstream", url)


@pytest.fixture
def git_downstream(tmp_dir, erepo_dir, git_dir, request):
remote = erepo_dir if "dvc" in request.fixturenames else git_dir
url = "file://{}".format(tmp_dir.resolve().as_posix())
url = f"file://{tmp_dir.resolve().as_posix()}"
remote.scm.gitpython.repo.create_remote("upstream", url)
return GitRemote(remote, "upstream", url)
4 changes: 2 additions & 2 deletions tests/func/machine/test_machine_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_machine_rename_success(
return_value=True,
)

os.makedirs((tmp_dir / ".dvc" / "tmp" / "machine" / "terraform" / "foo"))
os.makedirs(tmp_dir / ".dvc" / "tmp" / "machine" / "terraform" / "foo")

assert main(["machine", "rename", "foo", "bar"]) == 0
cap = capsys.readouterr()
Expand Down Expand Up @@ -158,7 +158,7 @@ def test_machine_rename_error(
tmp_dir, scm, dvc, machine_config, caplog, mocker
):
config_file = tmp_dir / ".dvc" / "config"
os.makedirs((tmp_dir / ".dvc" / "tmp" / "machine" / "terraform" / "foo"))
os.makedirs(tmp_dir / ".dvc" / "tmp" / "machine" / "terraform" / "foo")

def cmd_error(self, source, destination, **kwargs):
raise tpi.TPIError("test error")
Expand Down
3 changes: 1 addition & 2 deletions tests/func/test_ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def _to_pattern_info_list(str_list: List):


def walk_files(dvc, *args):
for fs_path in dvc.dvcignore.find(*args):
yield fs_path
yield from dvc.dvcignore.find(*args)


@pytest.mark.parametrize("filename", ["ignored", "тест"])
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/plots/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def filter_fields(datapoints: List[Dict], fields: List[str]):

def verify_image(tmp_dir, version, filename, content, html_path, json_result):
assert os.path.exists(html_path)
with open(html_path, "r", encoding="utf-8") as fd:
with open(html_path, encoding="utf-8") as fd:
html_content = fd.read()

image_data = {}
Expand Down Expand Up @@ -92,7 +92,7 @@ def verify_vega(
):

assert os.path.exists(html_path)
with open(html_path, "r", encoding="utf-8") as fd:
with open(html_path, encoding="utf-8") as fd:
html_content = fd.read()
assert _remove_blanks(
json.dumps(dpath.util.get(json_result, [filename, 0, "content"]))
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/command/test_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ def test_show_experiments_sort_by(capsys, sort_order):
rows = list(csv.reader(cap.out.strip().split("\n")))
# [3:] To skip header, workspace and baseline(master)
# which are not affected by order
params = tuple([int(row[-1]) for row in rows[3:]])
params = tuple(int(row[-1]) for row in rows[3:])

if sort_order == "asc":
assert params == (0, 1, 2)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/command/test_machine.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
from unittest.mock import call

import configobj
import pytest
from mock import call

from dvc.cli import parse_args
from dvc.commands.machine import (
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/fs/test_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import getpass
import os
from unittest.mock import mock_open, patch

import pytest
from mock import mock_open, patch

from dvc.fs import DEFAULT_SSH_PORT, SSHFileSystem

Expand Down
3 changes: 1 addition & 2 deletions tests/unit/remote/test_http.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ssl

from mock import patch
from unittest.mock import patch

from dvc.fs import HTTPFileSystem

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_analytics.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import platform
from unittest import mock

import mock
import pytest
from voluptuous import Any, Schema

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/utils/test_collections.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# pylint: disable=unidiomatic-typecheck
import json
from json import encoder
from unittest.mock import create_autospec

import pytest
from mock import create_autospec

from dvc.utils.collections import (
apply_diff,
Expand Down

0 comments on commit 844f77b

Please sign in to comment.