Fix pylint errors
Fix the pylint errors. e.g. useless-object-inheritance, super-with-arguments,
unnecessary-comprehension, and no-else-return.
Bug: 195474743
Test: acloud-dev create
Change-Id: Ia778cc4d7a05678b099cdbd146c9e762fd68437e
diff --git a/create/base_avd_create.py b/create/base_avd_create.py
index f7f8c70..fdc8256 100644
--- a/create/base_avd_create.py
+++ b/create/base_avd_create.py
@@ -22,7 +22,7 @@
from acloud.internal.lib import utils
-class BaseAVDCreate(object):
+class BaseAVDCreate():
"""Base class for all AVD intance creation classes."""
def _CreateAVD(self, avd_spec, no_prompts):
diff --git a/create/cheeps_remote_image_remote_instance.py b/create/cheeps_remote_image_remote_instance.py
index 5b1b70e..7d2ddcb 100644
--- a/create/cheeps_remote_image_remote_instance.py
+++ b/create/cheeps_remote_image_remote_instance.py
@@ -89,7 +89,7 @@
compute_client = cheeps_compute_client.CheepsComputeClient(
cfg, self.credentials)
- super(CheepsDeviceFactory, self).__init__(compute_client)
+ super().__init__(compute_client)
self._cfg = cfg
self._avd_spec = avd_spec
diff --git a/public/avd.py b/public/avd.py
index 4ac1bb3..ef4712e 100755
--- a/public/avd.py
+++ b/public/avd.py
@@ -35,7 +35,7 @@
logger = logging.getLogger(__name__)
-class AndroidVirtualDevice(object):
+class AndroidVirtualDevice():
"""Represent an Android device."""
def __init__(self, instance_name, ip=None, time_info=None, stage=None):
diff --git a/public/config.py b/public/config.py
index 2c8b2f8..8615cf8 100755
--- a/public/config.py
+++ b/public/config.py
@@ -162,38 +162,26 @@
self.ssh_private_key_path = usr_cfg.ssh_private_key_path
self.ssh_public_key_path = usr_cfg.ssh_public_key_path
self.storage_bucket_name = usr_cfg.storage_bucket_name
- self.metadata_variable = {
- key: val for key, val in
- six.iteritems(internal_cfg.default_usr_cfg.metadata_variable)
- }
+ self.metadata_variable = dict(
+ six.iteritems(internal_cfg.default_usr_cfg.metadata_variable))
self.metadata_variable.update(usr_cfg.metadata_variable)
- self.device_resolution_map = {
- device: resolution for device, resolution in
- six.iteritems(internal_cfg.device_resolution_map)
- }
- self.device_default_orientation_map = {
- device: orientation for device, orientation in
- six.iteritems(internal_cfg.device_default_orientation_map)
- }
- self.no_project_access_msg_map = {
- project: msg for project, msg in
- six.iteritems(internal_cfg.no_project_access_msg_map)
- }
+ self.device_resolution_map = dict(
+ six.iteritems(internal_cfg.device_resolution_map))
+ self.device_default_orientation_map = dict(
+ six.iteritems(internal_cfg.device_default_orientation_map))
+ self.no_project_access_msg_map = dict(
+ six.iteritems(internal_cfg.no_project_access_msg_map))
self.min_machine_size = internal_cfg.min_machine_size
self.disk_image_name = internal_cfg.disk_image_name
self.disk_image_mime_type = internal_cfg.disk_image_mime_type
self.disk_image_extension = internal_cfg.disk_image_extension
self.disk_raw_image_name = internal_cfg.disk_raw_image_name
self.disk_raw_image_extension = internal_cfg.disk_raw_image_extension
- self.valid_branch_and_min_build_id = {
- branch: min_build_id for branch, min_build_id in
- six.iteritems(internal_cfg.valid_branch_and_min_build_id)
- }
- self.precreated_data_image_map = {
- size_gb: image_name for size_gb, image_name in
- six.iteritems(internal_cfg.precreated_data_image)
- }
+ self.valid_branch_and_min_build_id = dict(
+ six.iteritems(internal_cfg.valid_branch_and_min_build_id))
+ self.precreated_data_image_map = dict(
+ six.iteritems(internal_cfg.precreated_data_image))
self.extra_data_disk_size_gb = (
usr_cfg.extra_data_disk_size_gb or
internal_cfg.default_usr_cfg.extra_data_disk_size_gb)
diff --git a/public/device_driver.py b/public/device_driver.py
index 192386c..73497dc 100755
--- a/public/device_driver.py
+++ b/public/device_driver.py
@@ -52,7 +52,7 @@
# pylint: disable=invalid-name
-class AndroidVirtualDevicePool(object):
+class AndroidVirtualDevicePool():
"""A class that manages a pool of devices."""
def __init__(self, cfg, devices=None):
diff --git a/public/device_driver_test.py b/public/device_driver_test.py
index e3c44f2..04ace4e 100644
--- a/public/device_driver_test.py
+++ b/public/device_driver_test.py
@@ -57,7 +57,7 @@
def setUp(self):
"""Set up the test."""
- super(DeviceDriverTest, self).setUp()
+ super().setUp()
self.build_client = mock.MagicMock()
self.Patch(android_build_client, "AndroidBuildClient",
return_value=self.build_client)
diff --git a/setup/base_task_runner.py b/setup/base_task_runner.py
index ded7161..7a2beeb 100644
--- a/setup/base_task_runner.py
+++ b/setup/base_task_runner.py
@@ -31,7 +31,7 @@
_PARAGRAPH_BREAK = "="
-class BaseTaskRunner(object):
+class BaseTaskRunner():
"""A basic task runner class for setup cmd."""
# WELCOME_MESSAGE and WELCOME_MESSAGE_TITLE should both be defined as
diff --git a/setup/gcp_setup_runner.py b/setup/gcp_setup_runner.py
index 26c1d06..e63c4f7 100644
--- a/setup/gcp_setup_runner.py
+++ b/setup/gcp_setup_runner.py
@@ -140,7 +140,7 @@
return False
-class GoogleSDKBins(object):
+class GoogleSDKBins():
"""Class to run tools in the Google SDK."""
def __init__(self, google_sdk_folder):
@@ -184,7 +184,7 @@
env=self._env, **kwargs)
-class GoogleAPIService(object):
+class GoogleAPIService():
"""Class to enable api service in the gcp project."""
def __init__(self, service_name, error_msg, required=False):
@@ -360,7 +360,7 @@
if project_changed:
logger.info("Your project changed. Start to run setup process.")
return True
- elif not self.client_id or not self.client_secret:
+ if not self.client_id or not self.client_secret:
logger.info("Client ID or client secret is empty. Start to run setup process.")
return True
logger.info("Project was unchanged and client ID didn't need to changed.")
diff --git a/setup/google_sdk.py b/setup/google_sdk.py
index 1343a3d..e216228 100644
--- a/setup/google_sdk.py
+++ b/setup/google_sdk.py
@@ -77,16 +77,16 @@
if is_64bits:
if os_type == LINUX:
return LINUX_GCP_SDK_64_URL
- elif os_type == MAC:
+ if os_type == MAC:
return MAC_GCP_SDK_64_URL
- elif os_type == WIN:
+ if os_type == WIN:
return WIN_GCP_SDK_64_URL
else:
if os_type == LINUX:
return LINUX_GCP_SDK_32_URL
- elif os_type == MAC:
+ if os_type == MAC:
return MAC_GCP_SDK_32_URL
- elif os_type == WIN:
+ if os_type == WIN:
return WIN_GCP_SDK_32_URL
raise errors.OSTypeError("no gcloud for os type: %s" % (os_type))
@@ -105,7 +105,7 @@
return False
-class GoogleSDK(object):
+class GoogleSDK():
"""Google SDK tools installer."""
def __init__(self):
@@ -155,7 +155,7 @@
builtin_gcloud = utils.FindExecutable(GCLOUD_BIN)
if builtin_gcloud:
return os.path.dirname(builtin_gcloud)
- elif os.path.exists(self._tmp_sdk_path):
+ if os.path.exists(self._tmp_sdk_path):
return self._tmp_sdk_path
raise errors.NoGoogleSDKDetected("no sdk path.")
diff --git a/setup/host_setup_runner_test.py b/setup/host_setup_runner_test.py
index 9ab1778..3123562 100644
--- a/setup/host_setup_runner_test.py
+++ b/setup/host_setup_runner_test.py
@@ -43,7 +43,7 @@
# pylint: disable=invalid-name
def setUp(self):
"""Set up the test."""
- super(CuttlefishHostSetupTest, self).setUp()
+ super().setUp()
self.CuttlefishHostSetup = CuttlefishHostSetup()
def testShouldRunFalse(self):
@@ -86,7 +86,7 @@
# pylint: disable=invalid-name
def setUp(self):
"""Set up the test."""
- super(AvdPkgInstallerTest, self).setUp()
+ super().setUp()
self.AvdPkgInstaller = AvdPkgInstaller()
def testShouldNotRun(self):
@@ -101,7 +101,7 @@
# pylint: disable=invalid-name
def setUp(self):
"""Set up the test."""
- super(CuttlefishCommonPkgInstallerTest, self).setUp()
+ super().setUp()
self.CuttlefishCommonPkgInstaller = CuttlefishCommonPkgInstaller()
def testShouldRun(self):
@@ -128,7 +128,7 @@
# pylint: disable=invalid-name
def setUp(self):
"""Set up the test."""
- super(MkcertPkgInstallerTest, self).setUp()
+ super().setUp()
self.MkcertPkgInstaller = MkcertPkgInstaller()
def testShouldRun(self):