Cleanup pylint errors in mainline_modules_sdks*.py
Bug: 218685706
Test: atest --host mainline_modules_sdks_test
packages/modules/common/build/mainline_modules_sdks.sh
pyformat -s 4 --force_quote_type double -i build/mainline_modules_sdks*.py
/usr/bin/pylint --rcfile $ANDROID_BUILD_TOP/tools/repohooks/tools/pylintrc build/mainline_modules_sdks*.py
Change-Id: I5ba3da7dcde6d44b1855b41bac8eb80e0f3a593c
This commit is contained in:
@@ -73,7 +73,7 @@ class SoongConfigBoilerplateInserter(FileTransformation):
|
||||
configModuleTypePrefix: str
|
||||
|
||||
def apply(self, producer, path):
|
||||
with open(path, "r+") as file:
|
||||
with open(path, "r+", encoding="utf8") as file:
|
||||
self._apply_transformation(producer, file)
|
||||
|
||||
def _apply_transformation(self, producer, file):
|
||||
@@ -246,12 +246,13 @@ class SnapshotBuilder:
|
||||
# This MUST be identical to the TARGET_BUILD_VARIANT used to build
|
||||
# the corresponding APEXes otherwise it could result in different
|
||||
# hidden API flags, see http://b/202398851#comment29 for more info.
|
||||
targetBuildVariant = os.environ.get("TARGET_BUILD_VARIANT", "user")
|
||||
target_build_variant = os.environ.get("TARGET_BUILD_VARIANT",
|
||||
"user")
|
||||
cmd = [
|
||||
"build/soong/soong_ui.bash",
|
||||
"--make-mode",
|
||||
"--soong-only",
|
||||
f"TARGET_BUILD_VARIANT={targetBuildVariant}",
|
||||
f"TARGET_BUILD_VARIANT={target_build_variant}",
|
||||
"TARGET_PRODUCT=mainline_sdk",
|
||||
"MODULE_BUILD_FROM_SOURCE=true",
|
||||
"out/soong/apex/depsinfo/new-allowed-deps.txt.check",
|
||||
@@ -335,20 +336,17 @@ class BuildRelease:
|
||||
return self.ordinal <= other.ordinal
|
||||
|
||||
|
||||
def create_no_dist_snapshot(build_release: BuildRelease,
|
||||
producer: "SdkDistProducer",
|
||||
def create_no_dist_snapshot(_: BuildRelease, __: "SdkDistProducer",
|
||||
modules: List["MainlineModule"]):
|
||||
"""A place holder dist snapshot creation function that does nothing."""
|
||||
print(f"create_no_dist_snapshot for modules {[m.apex for m in modules]}")
|
||||
return
|
||||
|
||||
|
||||
def create_sdk_snapshots_in_Soong(build_release: BuildRelease,
|
||||
def create_sdk_snapshots_in_soong(build_release: BuildRelease,
|
||||
producer: "SdkDistProducer",
|
||||
modules: List["MainlineModule"]):
|
||||
"""Builds sdks and populates the dist."""
|
||||
producer.produce_dist_for_build_release(build_release, modules)
|
||||
return
|
||||
|
||||
|
||||
def reuse_latest_sdk_snapshots(build_release: BuildRelease,
|
||||
@@ -356,7 +354,6 @@ def reuse_latest_sdk_snapshots(build_release: BuildRelease,
|
||||
modules: List["MainlineModule"]):
|
||||
"""Copies the snapshots from the latest build."""
|
||||
producer.populate_dist(build_release, build_release.sdk_versions, modules)
|
||||
return
|
||||
|
||||
|
||||
Q = BuildRelease(
|
||||
@@ -372,12 +369,12 @@ R = BuildRelease(
|
||||
S = BuildRelease(
|
||||
name="S",
|
||||
# Generate a snapshot for S using Soong.
|
||||
creator=create_sdk_snapshots_in_Soong,
|
||||
creator=create_sdk_snapshots_in_soong,
|
||||
)
|
||||
Tiramisu = BuildRelease(
|
||||
name="Tiramisu",
|
||||
# Generate a snapshot for Tiramisu using Soong.
|
||||
creator=create_sdk_snapshots_in_Soong,
|
||||
creator=create_sdk_snapshots_in_soong,
|
||||
)
|
||||
|
||||
# Insert additional BuildRelease definitions for following releases here,
|
||||
@@ -388,7 +385,7 @@ Tiramisu = BuildRelease(
|
||||
# before LEGACY_BUILD_RELEASE.
|
||||
LATEST = BuildRelease(
|
||||
name="latest",
|
||||
creator=create_sdk_snapshots_in_Soong,
|
||||
creator=create_sdk_snapshots_in_soong,
|
||||
# There are no build release specific environment variables to pass to
|
||||
# Soong.
|
||||
soong_env={},
|
||||
@@ -744,8 +741,8 @@ def filter_modules(modules):
|
||||
if target_build_apps:
|
||||
target_build_apps = target_build_apps.split()
|
||||
return [m for m in modules if m.apex in target_build_apps]
|
||||
else:
|
||||
return modules
|
||||
|
||||
return modules
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Unit tests for mainline_modules_sdks.py."""
|
||||
import dataclasses
|
||||
from pathlib import Path
|
||||
import os
|
||||
import tempfile
|
||||
import unittest
|
||||
import zipfile
|
||||
from unittest import mock
|
||||
|
||||
import mainline_modules_sdks as mm
|
||||
|
||||
@@ -127,7 +127,7 @@ class TestProduceDist(unittest.TestCase):
|
||||
sorted(files))
|
||||
|
||||
|
||||
def pathToTestData(relative_path):
|
||||
def path_to_test_data(relative_path):
|
||||
"""Construct a path to a test data file.
|
||||
|
||||
The relative_path is relative to the location of this file.
|
||||
@@ -147,8 +147,8 @@ def pathToTestData(relative_path):
|
||||
return os.path.join(this_file_without_ext + "_data", relative_path)
|
||||
|
||||
|
||||
def readTestData(relative_path):
|
||||
with open(pathToTestData(relative_path), "r") as f:
|
||||
def read_test_data(relative_path):
|
||||
with open(path_to_test_data(relative_path), "r", encoding="utf8") as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
@@ -156,19 +156,19 @@ class TestSoongConfigBoilerplateInserter(unittest.TestCase):
|
||||
|
||||
def apply_transformations(self, src, transformations, expected):
|
||||
producer = mm.SdkDistProducer(
|
||||
subprocess_runner=None,
|
||||
snapshot_builder=None,
|
||||
subprocess_runner=mock.Mock(mm.SubprocessRunner),
|
||||
snapshot_builder=mock.Mock(mm.SnapshotBuilder),
|
||||
script=self._testMethodName,
|
||||
)
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
path = os.path.join(tmp_dir, "Android.bp")
|
||||
with open(path, "w") as f:
|
||||
with open(path, "w", encoding="utf8") as f:
|
||||
f.write(src)
|
||||
|
||||
mm.apply_transformations(producer, tmp_dir, transformations)
|
||||
|
||||
with open(path, "r") as f:
|
||||
with open(path, "r", encoding="utf8") as f:
|
||||
result = f.read()
|
||||
|
||||
self.maxDiff = None
|
||||
@@ -181,9 +181,9 @@ class TestSoongConfigBoilerplateInserter(unittest.TestCase):
|
||||
that the correct Soong config module types and variables are used and
|
||||
that it imports the definitions from the correct location.
|
||||
"""
|
||||
src = readTestData("ipsec_Android.bp.input")
|
||||
src = read_test_data("ipsec_Android.bp.input")
|
||||
|
||||
expected = readTestData("ipsec_Android.bp.expected")
|
||||
expected = read_test_data("ipsec_Android.bp.expected")
|
||||
|
||||
module = MAINLINE_MODULES_BY_APEX["com.android.ipsec"]
|
||||
transformations = module.transformations()
|
||||
@@ -197,9 +197,9 @@ class TestSoongConfigBoilerplateInserter(unittest.TestCase):
|
||||
common mainline modules. This checks that the ART specific Soong config
|
||||
module types, variable and imports are used.
|
||||
"""
|
||||
src = readTestData("art_Android.bp.input")
|
||||
src = read_test_data("art_Android.bp.input")
|
||||
|
||||
expected = readTestData("art_Android.bp.expected")
|
||||
expected = read_test_data("art_Android.bp.expected")
|
||||
|
||||
module = MAINLINE_MODULES_BY_APEX["com.android.art"]
|
||||
transformations = module.transformations()
|
||||
|
||||
Reference in New Issue
Block a user