Skip to content

Commit 049367e

Browse files
authored
Merge pull request #3034 from mroutis/remove-py2-comments
py3: remove code related to py2 limitations
2 parents 82cdce0 + 71b15d2 commit 049367e

File tree

8 files changed

+14
-57
lines changed

8 files changed

+14
-57
lines changed

dvc/main.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from dvc.exceptions import NotDvcRepoError
1111
from dvc.external_repo import clean_repos
1212
from dvc.logger import FOOTER
13-
from dvc.remote.pool import close_pools
1413

1514

1615
# Workaround for CPython bug. See [1] and [2] for more info.
@@ -69,10 +68,6 @@ def main(argv=None):
6968
finally:
7069
logger.setLevel(outerLogLevel)
7170

72-
# Python 2 fails to close these clean occasionally and users see
73-
# weird error messages, so we do it manually
74-
close_pools()
75-
7671
# Remove cached repos in the end of the call, these are anonymous
7772
# so won't be reused by any other subsequent run anyway.
7873
clean_repos()

dvc/repo/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from dvc.ignore import CleanTree
88
from dvc.compat import fspath_py35
99

10-
from funcy import cached_property
10+
from funcy import cached_property, cat
1111

1212
from dvc.config import Config
1313
from dvc.exceptions import (
@@ -238,7 +238,6 @@ def used_cache(
238238
A dictionary with Schemes (representing output's location) as keys,
239239
and a list with the outputs' `dumpd` as values.
240240
"""
241-
from funcy.py2 import icat
242241
from dvc.cache import NamedCache
243242

244243
cache = NamedCache()
@@ -250,7 +249,7 @@ def used_cache(
250249
):
251250
targets = targets or [None]
252251

253-
pairs = icat(
252+
pairs = cat(
254253
self.collect_granular(
255254
target, recursive=recursive, with_deps=with_deps
256255
)

dvc/stage.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,7 @@ def is_data_source(self):
266266
@staticmethod
267267
def is_valid_filename(path):
268268
return (
269-
# path.endswith doesn't work for encoded unicode filenames on
270-
# Python 2 and since Stage.STAGE_FILE_SUFFIX is ascii then it is
271-
# not needed to decode the path from py2's str
272-
path[-len(Stage.STAGE_FILE_SUFFIX) :] == Stage.STAGE_FILE_SUFFIX
269+
path.endswith(Stage.STAGE_FILE_SUFFIX)
273270
or os.path.basename(path) == Stage.STAGE_FILE
274271
)
275272

tests/func/test_ignore.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@ def test_ignore(tmp_dir, dvc, monkeypatch):
2626

2727

2828
def test_ignore_unicode(tmp_dir, dvc):
29-
tmp_dir.gen({"dir": {"other": "text"}})
30-
# Path() doesn't handle unicode paths in Windows/Python 2
31-
# I don't know to debug it further, waiting till Python 2 EOL
32-
with open("dir/тест", "wb") as fd:
33-
fd.write("проверка".encode("utf-8"))
34-
29+
tmp_dir.gen({"dir": {"other": "text", "тест": "проверка"}})
3530
tmp_dir.gen(DvcIgnore.DVCIGNORE_FILE, "dir/тест")
3631

3732
assert _files_set("dir", dvc.tree) == {"dir/other"}

tests/func/test_output.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import os
2-
import sys
3-
41
import pytest
52

63
from dvc.output import _get
@@ -12,14 +9,7 @@
129
("s3://bucket/path", "s3"),
1310
("gs://bucket/path", "gs"),
1411
("ssh://example.com:/dir/path", "ssh"),
15-
pytest.param(
16-
"hdfs://example.com/dir/path",
17-
"hdfs",
18-
marks=pytest.mark.skipif(
19-
sys.version_info[0] == 2 and os.name == "nt",
20-
reason="Not supported for python 2 on Windows.",
21-
),
22-
),
12+
("hdfs://example.com/dir/path", "hdfs"),
2313
("path/to/file", "local"),
2414
("path\\to\\file", "local"),
2515
("file", "local"),

tests/remotes.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,9 @@ def get_gcp_url():
153153
return "gs://" + get_gcp_storagepath()
154154

155155

156-
# NOTE: staticmethod is only needed in Python 2
157156
class Local:
158-
should_test = staticmethod(lambda: True)
159-
get_url = staticmethod(get_local_url)
157+
should_test = lambda: True # noqa: E731
158+
get_url = get_local_url
160159

161160

162161
class S3:
@@ -183,7 +182,7 @@ def get_url():
183182

184183

185184
class S3Mocked(S3):
186-
should_test = staticmethod(lambda: True)
185+
should_test = lambda: True # noqa: E731
187186

188187
@classmethod
189188
@contextmanager
@@ -203,8 +202,8 @@ def put_objects(remote, objects):
203202

204203

205204
class GCP:
206-
should_test = staticmethod(_should_test_gcp)
207-
get_url = staticmethod(get_gcp_url)
205+
should_test = _should_test_gcp
206+
get_url = get_gcp_url
208207

209208
@classmethod
210209
@contextmanager
@@ -270,10 +269,10 @@ def get_url():
270269

271270

272271
class SSH:
273-
should_test = staticmethod(_should_test_ssh)
274-
get_url = staticmethod(get_ssh_url)
272+
should_test = _should_test_ssh
273+
get_url = get_ssh_url
275274

276275

277276
class HDFS:
278-
should_test = staticmethod(_should_test_hdfs)
279-
get_url = staticmethod(get_hdfs_url)
277+
should_test = _should_test_hdfs
278+
get_url = get_hdfs_url

tests/unit/dependency/test_hdfs.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
1-
import os
2-
import sys
3-
4-
import pytest
5-
61
from dvc.dependency.hdfs import DependencyHDFS
72
from tests.unit.dependency.test_local import TestDependencyLOCAL
83

94

10-
@pytest.mark.skipif(
11-
sys.version_info[0] == 2 and os.name == "nt",
12-
reason="Not supported for python 2 on Windows.",
13-
)
145
class TestDependencyHDFS(TestDependencyLOCAL):
156
def _get_cls(self):
167
return DependencyHDFS

tests/unit/output/test_hdfs.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
1-
import os
2-
import sys
3-
4-
import pytest
5-
61
from dvc.output.hdfs import OutputHDFS
72
from tests.unit.output.test_local import TestOutputLOCAL
83

94

10-
@pytest.mark.skipif(
11-
sys.version_info[0] == 2 and os.name == "nt",
12-
reason="Not supported for python 2 on Windows.",
13-
)
145
class TestOutputHDFS(TestOutputLOCAL):
156
def _get_cls(self):
167
return OutputHDFS

0 commit comments

Comments
 (0)