mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
py3: remove code related to py2 limitations
This commit is contained in:
@@ -10,7 +10,6 @@ from dvc.exceptions import DvcParserError
|
||||
from dvc.exceptions import NotDvcRepoError
|
||||
from dvc.external_repo import clean_repos
|
||||
from dvc.logger import FOOTER
|
||||
from dvc.remote.pool import close_pools
|
||||
|
||||
|
||||
# Workaround for CPython bug. See [1] and [2] for more info.
|
||||
@@ -68,10 +67,6 @@ def main(argv=None):
|
||||
finally:
|
||||
logger.setLevel(outerLogLevel)
|
||||
|
||||
# Python 2 fails to close these clean occasionally and users see
|
||||
# weird error messages, so we do it manually
|
||||
close_pools()
|
||||
|
||||
# Remove cached repos in the end of the call, these are anonymous
|
||||
# so won't be reused by any other subsequent run anyway.
|
||||
clean_repos()
|
||||
|
||||
@@ -7,7 +7,7 @@ from itertools import chain
|
||||
from dvc.ignore import CleanTree
|
||||
from dvc.compat import fspath_py35
|
||||
|
||||
from funcy import cached_property
|
||||
from funcy import cached_property, cat
|
||||
|
||||
from dvc.config import Config
|
||||
from dvc.exceptions import (
|
||||
@@ -238,7 +238,6 @@ class Repo(object):
|
||||
A dictionary with Schemes (representing output's location) as keys,
|
||||
and a list with the outputs' `dumpd` as values.
|
||||
"""
|
||||
from funcy.py2 import icat
|
||||
from dvc.cache import NamedCache
|
||||
|
||||
cache = NamedCache()
|
||||
@@ -250,7 +249,7 @@ class Repo(object):
|
||||
):
|
||||
targets = targets or [None]
|
||||
|
||||
pairs = icat(
|
||||
pairs = cat(
|
||||
self.collect_granular(
|
||||
target, recursive=recursive, with_deps=with_deps
|
||||
)
|
||||
|
||||
+1
-4
@@ -264,10 +264,7 @@ class Stage(object):
|
||||
@staticmethod
|
||||
def is_valid_filename(path):
|
||||
return (
|
||||
# path.endswith doesn't work for encoded unicode filenames on
|
||||
# Python 2 and since Stage.STAGE_FILE_SUFFIX is ascii then it is
|
||||
# not needed to decode the path from py2's str
|
||||
path[-len(Stage.STAGE_FILE_SUFFIX) :] == Stage.STAGE_FILE_SUFFIX
|
||||
path.endswith(Stage.STAGE_FILE_SUFFIX)
|
||||
or os.path.basename(path) == Stage.STAGE_FILE
|
||||
)
|
||||
|
||||
|
||||
@@ -26,12 +26,7 @@ def test_ignore(tmp_dir, dvc, monkeypatch):
|
||||
|
||||
|
||||
def test_ignore_unicode(tmp_dir, dvc):
|
||||
tmp_dir.gen({"dir": {"other": "text"}})
|
||||
# Path() doesn't handle unicode paths in Windows/Python 2
|
||||
# I don't know to debug it further, waiting till Python 2 EOL
|
||||
with open("dir/тест", "wb") as fd:
|
||||
fd.write("проверка".encode("utf-8"))
|
||||
|
||||
tmp_dir.gen({"dir": {"other": "text", "тест": "проверка"}})
|
||||
tmp_dir.gen(DvcIgnore.DVCIGNORE_FILE, "dir/тест")
|
||||
|
||||
assert _files_set("dir", dvc.tree) == {"dir/other"}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
from dvc.output import _get
|
||||
@@ -12,14 +9,7 @@ TESTS = [
|
||||
("s3://bucket/path", "s3"),
|
||||
("gs://bucket/path", "gs"),
|
||||
("ssh://example.com:/dir/path", "ssh"),
|
||||
pytest.param(
|
||||
"hdfs://example.com/dir/path",
|
||||
"hdfs",
|
||||
marks=pytest.mark.skipif(
|
||||
sys.version_info[0] == 2 and os.name == "nt",
|
||||
reason="Not supported for python 2 on Windows.",
|
||||
),
|
||||
),
|
||||
("hdfs://example.com/dir/path", "hdfs"),
|
||||
("path/to/file", "local"),
|
||||
("path\\to\\file", "local"),
|
||||
("file", "local"),
|
||||
|
||||
+9
-10
@@ -153,10 +153,9 @@ def get_gcp_url():
|
||||
return "gs://" + get_gcp_storagepath()
|
||||
|
||||
|
||||
# NOTE: staticmethod is only needed in Python 2
|
||||
class Local:
|
||||
should_test = staticmethod(lambda: True)
|
||||
get_url = staticmethod(get_local_url)
|
||||
should_test = lambda: True # noqa: E731
|
||||
get_url = get_local_url
|
||||
|
||||
|
||||
class S3:
|
||||
@@ -183,7 +182,7 @@ class S3:
|
||||
|
||||
|
||||
class S3Mocked(S3):
|
||||
should_test = staticmethod(lambda: True)
|
||||
should_test = lambda: True # noqa: E731
|
||||
|
||||
@classmethod
|
||||
@contextmanager
|
||||
@@ -203,8 +202,8 @@ class S3Mocked(S3):
|
||||
|
||||
|
||||
class GCP:
|
||||
should_test = staticmethod(_should_test_gcp)
|
||||
get_url = staticmethod(get_gcp_url)
|
||||
should_test = _should_test_gcp
|
||||
get_url = get_gcp_url
|
||||
|
||||
@classmethod
|
||||
@contextmanager
|
||||
@@ -270,10 +269,10 @@ class OSS:
|
||||
|
||||
|
||||
class SSH:
|
||||
should_test = staticmethod(_should_test_ssh)
|
||||
get_url = staticmethod(get_ssh_url)
|
||||
should_test = _should_test_ssh
|
||||
get_url = get_ssh_url
|
||||
|
||||
|
||||
class HDFS:
|
||||
should_test = staticmethod(_should_test_hdfs)
|
||||
get_url = staticmethod(get_hdfs_url)
|
||||
should_test = _should_test_hdfs
|
||||
get_url = get_hdfs_url
|
||||
|
||||
@@ -1,16 +1,7 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
from dvc.dependency.hdfs import DependencyHDFS
|
||||
from tests.unit.dependency.test_local import TestDependencyLOCAL
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.version_info[0] == 2 and os.name == "nt",
|
||||
reason="Not supported for python 2 on Windows.",
|
||||
)
|
||||
class TestDependencyHDFS(TestDependencyLOCAL):
|
||||
def _get_cls(self):
|
||||
return DependencyHDFS
|
||||
|
||||
@@ -1,16 +1,7 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
from dvc.output.hdfs import OutputHDFS
|
||||
from tests.unit.output.test_local import TestOutputLOCAL
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.version_info[0] == 2 and os.name == "nt",
|
||||
reason="Not supported for python 2 on Windows.",
|
||||
)
|
||||
class TestOutputHDFS(TestOutputLOCAL):
|
||||
def _get_cls(self):
|
||||
return OutputHDFS
|
||||
|
||||
Reference in New Issue
Block a user