diff --git a/dvc/main.py b/dvc/main.py index a2fa79d144..76b6f5dc66 100644 --- a/dvc/main.py +++ b/dvc/main.py @@ -10,7 +10,6 @@ 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() diff --git a/dvc/repo/__init__.py b/dvc/repo/__init__.py index 7025d5a175..af68180aab 100644 --- a/dvc/repo/__init__.py +++ b/dvc/repo/__init__.py @@ -7,7 +7,7 @@ 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 @@ def used_cache( 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 @@ def used_cache( ): targets = targets or [None] - pairs = icat( + pairs = cat( self.collect_granular( target, recursive=recursive, with_deps=with_deps ) diff --git a/dvc/stage.py b/dvc/stage.py index 1a94eed5f5..b5f04752d2 100644 --- a/dvc/stage.py +++ b/dvc/stage.py @@ -264,10 +264,7 @@ def is_data_source(self): @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 ) diff --git a/tests/func/test_ignore.py b/tests/func/test_ignore.py index ab1d4e5b7f..7383121dee 100644 --- a/tests/func/test_ignore.py +++ b/tests/func/test_ignore.py @@ -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"} diff --git a/tests/func/test_output.py b/tests/func/test_output.py index 19744db32a..93faa6304f 100644 --- a/tests/func/test_output.py +++ b/tests/func/test_output.py @@ -1,6 +1,3 @@ -import os -import sys - import pytest from dvc.output import _get @@ -12,14 +9,7 @@ ("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"), diff --git a/tests/remotes.py b/tests/remotes.py index cdf4bf663d..387b2a8aad 100644 --- a/tests/remotes.py +++ b/tests/remotes.py @@ -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 @@ def get_url(): class S3Mocked(S3): - should_test = staticmethod(lambda: True) + should_test = lambda: True # noqa: E731 @classmethod @contextmanager @@ -203,8 +202,8 @@ def put_objects(remote, objects): 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 @@ def get_url(): 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 diff --git a/tests/unit/dependency/test_hdfs.py b/tests/unit/dependency/test_hdfs.py index f85ce1cccd..941216cfdc 100644 --- a/tests/unit/dependency/test_hdfs.py +++ b/tests/unit/dependency/test_hdfs.py @@ -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 diff --git a/tests/unit/output/test_hdfs.py b/tests/unit/output/test_hdfs.py index 8f80d1a596..a07e9fb942 100644 --- a/tests/unit/output/test_hdfs.py +++ b/tests/unit/output/test_hdfs.py @@ -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