diff options
-rw-r--r-- | git_config.py | 4 | ||||
-rw-r--r-- | release/update_manpages.py | 6 | ||||
-rw-r--r-- | repo_trace.py | 4 | ||||
-rw-r--r-- | subcmds/abandon.py | 6 | ||||
-rw-r--r-- | subcmds/selfupdate.py | 4 | ||||
-rw-r--r-- | subcmds/sync.py | 4 | ||||
-rw-r--r-- | tests/test_repo_logging.py | 8 | ||||
-rw-r--r-- | tests/test_wrapper.py | 8 |
8 files changed, 24 insertions, 20 deletions
diff --git a/git_config.py b/git_config.py index 87ed9765..971066ef 100644 --- a/git_config.py +++ b/git_config.py | |||
@@ -15,7 +15,7 @@ | |||
15 | import contextlib | 15 | import contextlib |
16 | import datetime | 16 | import datetime |
17 | import errno | 17 | import errno |
18 | from http.client import HTTPException | 18 | import http.client |
19 | import json | 19 | import json |
20 | import os | 20 | import os |
21 | import re | 21 | import re |
@@ -650,7 +650,7 @@ class Remote(object): | |||
650 | raise UploadError("%s: %s" % (self.review, str(e))) | 650 | raise UploadError("%s: %s" % (self.review, str(e))) |
651 | except urllib.error.URLError as e: | 651 | except urllib.error.URLError as e: |
652 | raise UploadError("%s: %s" % (self.review, str(e))) | 652 | raise UploadError("%s: %s" % (self.review, str(e))) |
653 | except HTTPException as e: | 653 | except http.client.HTTPException as e: |
654 | raise UploadError( | 654 | raise UploadError( |
655 | "%s: %s" % (self.review, e.__class__.__name__) | 655 | "%s: %s" % (self.review, e.__class__.__name__) |
656 | ) | 656 | ) |
diff --git a/release/update_manpages.py b/release/update_manpages.py index cd2acc01..cb687245 100644 --- a/release/update_manpages.py +++ b/release/update_manpages.py | |||
@@ -18,8 +18,8 @@ Most code lives in this module so it can be unittested. | |||
18 | """ | 18 | """ |
19 | 19 | ||
20 | from pathlib import Path | 20 | from pathlib import Path |
21 | from functools import partial | ||
22 | import argparse | 21 | import argparse |
22 | import functools | ||
23 | import multiprocessing | 23 | import multiprocessing |
24 | import os | 24 | import os |
25 | import re | 25 | import re |
@@ -112,7 +112,9 @@ def main(argv): | |||
112 | 112 | ||
113 | # Run all cmd in parallel, and wait for them to finish. | 113 | # Run all cmd in parallel, and wait for them to finish. |
114 | with multiprocessing.Pool() as pool: | 114 | with multiprocessing.Pool() as pool: |
115 | pool.map(partial(worker, cwd=tempdir, check=True), cmdlist) | 115 | pool.map( |
116 | functools.partial(worker, cwd=tempdir, check=True), cmdlist | ||
117 | ) | ||
116 | 118 | ||
117 | for tmp_path in MANDIR.glob("*.1.tmp"): | 119 | for tmp_path in MANDIR.glob("*.1.tmp"): |
118 | path = tmp_path.parent / tmp_path.stem | 120 | path = tmp_path.parent / tmp_path.stem |
diff --git a/repo_trace.py b/repo_trace.py index 49462174..01beaf8e 100644 --- a/repo_trace.py +++ b/repo_trace.py | |||
@@ -20,11 +20,11 @@ Temporary: Tracing is always on. Set `REPO_TRACE=0` to turn off. | |||
20 | To also include trace outputs in stderr do `repo --trace_to_stderr ...` | 20 | To also include trace outputs in stderr do `repo --trace_to_stderr ...` |
21 | """ | 21 | """ |
22 | 22 | ||
23 | import contextlib | ||
23 | import sys | 24 | import sys |
24 | import os | 25 | import os |
25 | import time | 26 | import time |
26 | import tempfile | 27 | import tempfile |
27 | from contextlib import ContextDecorator | ||
28 | 28 | ||
29 | import platform_utils | 29 | import platform_utils |
30 | 30 | ||
@@ -68,7 +68,7 @@ def _SetTraceFile(quiet): | |||
68 | _TRACE_FILE = _GetTraceFile(quiet) | 68 | _TRACE_FILE = _GetTraceFile(quiet) |
69 | 69 | ||
70 | 70 | ||
71 | class Trace(ContextDecorator): | 71 | class Trace(contextlib.ContextDecorator): |
72 | """Used to capture and save git traces.""" | 72 | """Used to capture and save git traces.""" |
73 | 73 | ||
74 | def _time(self): | 74 | def _time(self): |
diff --git a/subcmds/abandon.py b/subcmds/abandon.py index 896b348f..1499c75e 100644 --- a/subcmds/abandon.py +++ b/subcmds/abandon.py | |||
@@ -12,7 +12,7 @@ | |||
12 | # See the License for the specific language governing permissions and | 12 | # See the License for the specific language governing permissions and |
13 | # limitations under the License. | 13 | # limitations under the License. |
14 | 14 | ||
15 | from collections import defaultdict | 15 | import collections |
16 | import functools | 16 | import functools |
17 | import itertools | 17 | import itertools |
18 | import sys | 18 | import sys |
@@ -88,8 +88,8 @@ It is equivalent to "git branch -D <branchname>". | |||
88 | 88 | ||
89 | def Execute(self, opt, args): | 89 | def Execute(self, opt, args): |
90 | nb = args[0].split() | 90 | nb = args[0].split() |
91 | err = defaultdict(list) | 91 | err = collections.defaultdict(list) |
92 | success = defaultdict(list) | 92 | success = collections.defaultdict(list) |
93 | aggregate_errors = [] | 93 | aggregate_errors = [] |
94 | all_projects = self.GetProjects( | 94 | all_projects = self.GetProjects( |
95 | args[1:], all_manifests=not opt.this_manifest_only | 95 | args[1:], all_manifests=not opt.this_manifest_only |
diff --git a/subcmds/selfupdate.py b/subcmds/selfupdate.py index 00376b66..983fd630 100644 --- a/subcmds/selfupdate.py +++ b/subcmds/selfupdate.py | |||
@@ -12,7 +12,7 @@ | |||
12 | # See the License for the specific language governing permissions and | 12 | # See the License for the specific language governing permissions and |
13 | # limitations under the License. | 13 | # limitations under the License. |
14 | 14 | ||
15 | from optparse import SUPPRESS_HELP | 15 | import optparse |
16 | import sys | 16 | import sys |
17 | 17 | ||
18 | from command import Command, MirrorSafeCommand | 18 | from command import Command, MirrorSafeCommand |
@@ -52,7 +52,7 @@ need to be performed by an end-user. | |||
52 | "--repo-upgraded", | 52 | "--repo-upgraded", |
53 | dest="repo_upgraded", | 53 | dest="repo_upgraded", |
54 | action="store_true", | 54 | action="store_true", |
55 | help=SUPPRESS_HELP, | 55 | help=optparse.SUPPRESS_HELP, |
56 | ) | 56 | ) |
57 | 57 | ||
58 | def Execute(self, opt, args): | 58 | def Execute(self, opt, args): |
diff --git a/subcmds/sync.py b/subcmds/sync.py index 159771eb..74bc4557 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -19,7 +19,7 @@ import io | |||
19 | import json | 19 | import json |
20 | import multiprocessing | 20 | import multiprocessing |
21 | import netrc | 21 | import netrc |
22 | from optparse import SUPPRESS_HELP | 22 | import optparse |
23 | import os | 23 | import os |
24 | import socket | 24 | import socket |
25 | import sys | 25 | import sys |
@@ -481,7 +481,7 @@ later is required to fix a server side protocol bug. | |||
481 | "--repo-upgraded", | 481 | "--repo-upgraded", |
482 | dest="repo_upgraded", | 482 | dest="repo_upgraded", |
483 | action="store_true", | 483 | action="store_true", |
484 | help=SUPPRESS_HELP, | 484 | help=optparse.SUPPRESS_HELP, |
485 | ) | 485 | ) |
486 | 486 | ||
487 | def _GetBranch(self, manifest_project): | 487 | def _GetBranch(self, manifest_project): |
diff --git a/tests/test_repo_logging.py b/tests/test_repo_logging.py index ba8a9a9e..5402a90b 100644 --- a/tests/test_repo_logging.py +++ b/tests/test_repo_logging.py | |||
@@ -14,7 +14,7 @@ | |||
14 | 14 | ||
15 | """Unit test for repo_logging module.""" | 15 | """Unit test for repo_logging module.""" |
16 | import unittest | 16 | import unittest |
17 | from unittest.mock import MagicMock | 17 | from unittest import mock |
18 | 18 | ||
19 | from repo_logging import RepoLogger | 19 | from repo_logging import RepoLogger |
20 | 20 | ||
@@ -30,7 +30,7 @@ class TestRepoLogger(unittest.TestCase): | |||
30 | nonlocal result | 30 | nonlocal result |
31 | result = log.getMessage() | 31 | result = log.getMessage() |
32 | 32 | ||
33 | mock_out = MagicMock() | 33 | mock_out = mock.MagicMock() |
34 | mock_out.level = 0 | 34 | mock_out.level = 0 |
35 | mock_out.handle = mock_handler | 35 | mock_out.handle = mock_handler |
36 | logger.addHandler(mock_out) | 36 | logger.addHandler(mock_out) |
@@ -49,7 +49,7 @@ class TestRepoLogger(unittest.TestCase): | |||
49 | nonlocal result | 49 | nonlocal result |
50 | result = log.getMessage() | 50 | result = log.getMessage() |
51 | 51 | ||
52 | mock_out = MagicMock() | 52 | mock_out = mock.MagicMock() |
53 | mock_out.level = 0 | 53 | mock_out.level = 0 |
54 | mock_out.handle = mock_handler | 54 | mock_out.handle = mock_handler |
55 | logger.addHandler(mock_out) | 55 | logger.addHandler(mock_out) |
@@ -88,7 +88,7 @@ class TestRepoLogger(unittest.TestCase): | |||
88 | nonlocal result | 88 | nonlocal result |
89 | result.append(log.getMessage()) | 89 | result.append(log.getMessage()) |
90 | 90 | ||
91 | mock_out = MagicMock() | 91 | mock_out = mock.MagicMock() |
92 | mock_out.level = 0 | 92 | mock_out.level = 0 |
93 | mock_out.handle = mock_handler | 93 | mock_out.handle = mock_handler |
94 | logger.addHandler(mock_out) | 94 | logger.addHandler(mock_out) |
diff --git a/tests/test_wrapper.py b/tests/test_wrapper.py index 4e8263b2..ef4dce10 100644 --- a/tests/test_wrapper.py +++ b/tests/test_wrapper.py | |||
@@ -14,7 +14,7 @@ | |||
14 | 14 | ||
15 | """Unittests for the wrapper.py module.""" | 15 | """Unittests for the wrapper.py module.""" |
16 | 16 | ||
17 | from io import StringIO | 17 | import io |
18 | import os | 18 | import os |
19 | import re | 19 | import re |
20 | import sys | 20 | import sys |
@@ -47,8 +47,10 @@ class RepoWrapperUnitTest(RepoWrapperTestCase): | |||
47 | def test_version(self): | 47 | def test_version(self): |
48 | """Make sure _Version works.""" | 48 | """Make sure _Version works.""" |
49 | with self.assertRaises(SystemExit) as e: | 49 | with self.assertRaises(SystemExit) as e: |
50 | with mock.patch("sys.stdout", new_callable=StringIO) as stdout: | 50 | with mock.patch("sys.stdout", new_callable=io.StringIO) as stdout: |
51 | with mock.patch("sys.stderr", new_callable=StringIO) as stderr: | 51 | with mock.patch( |
52 | "sys.stderr", new_callable=io.StringIO | ||
53 | ) as stderr: | ||
52 | self.wrapper._Version() | 54 | self.wrapper._Version() |
53 | self.assertEqual(0, e.exception.code) | 55 | self.assertEqual(0, e.exception.code) |
54 | self.assertEqual("", stderr.getvalue()) | 56 | self.assertEqual("", stderr.getvalue()) |