api: Fix bad docblock indentation.
Also fix resulting line-too-long lint errors, but not other
existing instances of line-too-long errors.
BUG=b:233893248
TEST=cros lint
Change-Id: I75ebbcab5236551dea618f34783ec2fea7af60f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3943256
Tested-by: Alex Klein <saklein@chromium.org>
Reviewed-by: Sloan Johnson <sloanjohnson@google.com>
Auto-Submit: Alex Klein <saklein@chromium.org>
Commit-Queue: Sloan Johnson <sloanjohnson@google.com>
diff --git a/api/api_config.py b/api/api_config.py
index efb9340..d3ab5c2 100644
--- a/api/api_config.py
+++ b/api/api_config.py
@@ -99,9 +99,9 @@
"""Get the config as a proto.
Args:
- for_inside_execution: Allows avoiding propagating configs that are
- irrelevant for the build api process executed inside the chroot.
- Enabled by default.
+ for_inside_execution: Allows avoiding propagating configs that are
+ irrelevant for the build api process executed inside the chroot.
+ Enabled by default.
"""
config = build_api_config_pb2.BuildApiConfig()
config.call_type = self.ENUM_TYPE_MAP[self._call_type]
@@ -119,7 +119,7 @@
"""Build an ApiConfig instance from a BuildApiConfig message.
Args:
- config_proto: The proto config.
+ config_proto: The proto config.
"""
if config_proto.call_type not in ApiConfig.TYPE_ENUM_MAP:
diff --git a/api/compile_build_api_proto.py b/api/compile_build_api_proto.py
index 463c238..cc4657b 100644
--- a/api/compile_build_api_proto.py
+++ b/api/compile_build_api_proto.py
@@ -121,7 +121,7 @@
diagnosing accidental __init__.py changes.
Args:
- directory: Path to be cleaned up.
+ directory: Path to be cleaned up.
"""
logging.info("Cleaning old files from %s.", directory)
for current in directory.rglob("*_pb2.py"):
@@ -143,11 +143,11 @@
"""Generate the proto files from the |source| tree into |output|.
Args:
- source: Path to the proto source root directory.
- output: Path to the output root directory.
- protoc_version: Which protoc to use.
- dir_subset: The subset of the proto to compile.
- protoc_bin_path: The protoc command to use.
+ source: Path to the proto source root directory.
+ output: Path to the output root directory.
+ protoc_version: Which protoc to use.
+ dir_subset: The subset of the proto to compile.
+ protoc_bin_path: The protoc command to use.
"""
logging.info("Generating files to %s.", output)
osutils.SafeMakedirs(output)
@@ -206,9 +206,9 @@
"""Do postprocessing on the generated files.
Args:
- directory: The root directory containing the generated files that are
- to be processed.
- protoc_version: Which protoc is being used to generate the files.
+ directory: The root directory containing the generated files that are
+ to be processed.
+ protoc_version: Which protoc is being used to generate the files.
"""
logging.info("Postprocessing: Fix imports in %s.", directory)
# We are using a negative address here (the /address/! portion of the sed
@@ -270,10 +270,10 @@
in the default location.
Args:
- output: The output directory.
- protoc_version: Which protoc to use for the compile.
- dir_subset: What proto to compile.
- postprocess: Whether to run the postprocess step.
+ output: The output directory.
+ protoc_version: Which protoc to use for the compile.
+ dir_subset: What proto to compile.
+ postprocess: Whether to run the postprocess step.
"""
protoc_version = protoc_version or ProtocVersion.CHROMITE
source = protoc_version.get_proto_dir() / "src"
diff --git a/api/faux.py b/api/faux.py
index 4ea3c1f..3bae1ba 100644
--- a/api/faux.py
+++ b/api/faux.py
@@ -16,9 +16,9 @@
single function.
Args:
- faux_result_factory: A function with the same signature as a regular
- API endpoint function that populates the output with success or error
- results, as requested, without executing the endpoint.
+ faux_result_factory: A function with the same signature as a regular
+ API endpoint function that populates the output with success or
+ error results, as requested, without executing the endpoint.
"""
assert faux_result_factory
@@ -41,8 +41,8 @@
"""A decorator to handle mock call responses.
Args:
- faux_result_factory: A function with the same signature as a regular
- API endpoint function that populates the output
+ faux_result_factory: A function with the same signature as a regular
+ API endpoint function that populates the output
"""
assert faux_result_factory
diff --git a/api/field_handler.py b/api/field_handler.py
index faedcfb..51dec04 100644
--- a/api/field_handler.py
+++ b/api/field_handler.py
@@ -124,13 +124,13 @@
"""Path handler initialization.
Args:
- field: The Path message.
- destination: The destination base path.
- delete: Whether the copied file(s) should be deleted on cleanup.
- prefix: A path prefix to remove from the destination path when moving
- files inside the chroot, or to add to the source paths when moving files
- out of the chroot.
- reset: Whether to reset the state on cleanup.
+ field: The Path message.
+ destination: The destination base path.
+ delete: Whether the copied file(s) should be deleted on cleanup.
+ prefix: A path prefix to remove from the destination path when
+ moving files inside the chroot, or to add to the source paths
+ when moving files out of the chroot.
+ reset: Whether to reset the state on cleanup.
"""
assert isinstance(field, common_pb2.Path)
assert field.path
@@ -152,9 +152,9 @@
"""Copy the file or directory to its destination.
Args:
- direction: The direction files are being copied (into or out of the
- chroot). Specifying the direction allows avoiding performing unnecessary
- copies.
+ direction: The direction files are being copied (into or out of the
+ chroot). Specifying the direction allows avoiding performing
+ unnecessary copies.
"""
if self._transferred:
return
@@ -256,14 +256,14 @@
"""Context manager function to transfer and cleanup all Path messages.
Args:
- message: A message whose Path messages should be transferred.
- destination: The base destination path.
- delete: Whether the file(s) should be deleted.
- prefix: A prefix path to remove from the final destination path in the Path
- message (i.e. remove the chroot path).
+ message: A message whose Path messages should be transferred.
+ destination: The base destination path.
+ delete: Whether the file(s) should be deleted.
+ prefix: A prefix path to remove from the final destination path in the
+ Path message (i.e. remove the chroot path).
Yields:
- list[PathHandler]: The path handlers.
+ list[PathHandler]: The path handlers.
"""
assert destination
@@ -288,18 +288,18 @@
"""Context manager function to handle SyncedDir messages.
The sync semantics are effectively:
- rsync -r --del source/ destination/
- * The endpoint runs. *
- rsync -r --del destination/ source/
+ rsync -r --del source/ destination/
+ * The endpoint runs. *
+ rsync -r --del destination/ source/
Args:
- message: A message whose SyncedPath messages should be synced.
- destination: The destination path.
- prefix: A prefix path to remove from the final destination path in the Path
- message (i.e. remove the chroot path).
+ message: A message whose SyncedPath messages should be synced.
+ destination: The destination path.
+ prefix: A prefix path to remove from the final destination path in the
+ Path message (i.e. remove the chroot path).
Yields:
- The handlers.
+ The handlers.
"""
assert destination
@@ -330,10 +330,10 @@
"""Transfer all response Path messages to the request's ResultPath.
Args:
- request_message: The request message containing a ResultPath message.
- response_message: The response message whose Path message(s) are to be
- transferred.
- chroot: The chroot the files are being copied out of.
+ request_message: The request message containing a ResultPath message.
+ response_message: The response message whose Path message(s) are to be
+ transferred.
+ chroot: The chroot the files are being copied out of.
"""
# Find the ResultPath.
for descriptor in request_message.DESCRIPTOR.fields:
diff --git a/api/message_util.py b/api/message_util.py
index 9225047..db8bcf2 100644
--- a/api/message_util.py
+++ b/api/message_util.py
@@ -92,8 +92,8 @@
"""Deserialize the data into the given message.
Args:
- data: The message data to deserialize.
- message: The message to load the data into.
+ data: The message data to deserialize.
+ message: The message to load the data into.
"""
# pylint: disable=unused-argument
@@ -101,10 +101,10 @@
"""Serialize the message data.
Args:
- message: The message to be serialized.
+ message: The message to be serialized.
Returns:
- The message's serialized data.
+ The message's serialized data.
"""
return ""
@@ -173,12 +173,12 @@
api data.
Examples:
- message_handler = MessageHandler(path, ...)
- message = ...
- # Parse path into message.
- message_handler.read_into(message)
- # Write message to a different file.
- message_handler.write_into(message, path=other_path)
+ message_handler = MessageHandler(path, ...)
+ message = ...
+ # Parse path into message.
+ message_handler.read_into(message)
+ # Write message to a different file.
+ message_handler.write_into(message, path=other_path)
"""
def __init__(
@@ -193,15 +193,15 @@
"""MessageHandler init.
Args:
- path: The path to the main file associated with this handler.
- serializer: The serializer to be used for the messages.
- binary: Whether the serialized content is binary.
- input_arg: The --input-x argument used for this type. Used for
- reexecution inside the chroot.
- output_arg: The --output-x argument used for this type. Used for
- reexecution inside the chroot.
- config_arg: The --config-x argument used for this type. Used for
- reexecution inside the chroot.
+ path: The path to the main file associated with this handler.
+ serializer: The serializer to be used for the messages.
+ binary: Whether the serialized content is binary.
+ input_arg: The --input-x argument used for this type. Used for
+ reexecution inside the chroot.
+ output_arg: The --output-x argument used for this type. Used for
+ reexecution inside the chroot.
+ config_arg: The --config-x argument used for this type. Used for
+ reexecution inside the chroot.
"""
self.path = path
self.serializer = serializer
@@ -217,12 +217,12 @@
"""Read a file containing serialized data into a message.
Args:
- message: The message to populate.
- path: A path to read. Uses the instance's path when not given.
+ message: The message to populate.
+ path: A path to read. Uses the instance's path when not given.
Raises:
- InvalidInputFileError: When a path has not been given, does not exist,
- or cannot be read.
+ InvalidInputFileError: When a path has not been given, does not
+ exist, or cannot be read.
"""
target_path = path or self.path
if not target_path:
@@ -248,11 +248,11 @@
"""Write serialized data from the message to a file.
Args:
- message: The message to serialize and persist.
- path: An optional override of the instance's path.
+ message: The message to serialize and persist.
+ path: An optional override of the instance's path.
Raises:
- InvalidOutputFileError: When no path given, or it cannot be written to.
+ InvalidOutputFileError: When no path given, or it cannot be written to.
"""
if not path and not self.path:
raise InvalidOutputFileError("No output file has been specified.")
diff --git a/api/metrics.py b/api/metrics.py
index 8b66cd3..b51e5e1 100644
--- a/api/metrics.py
+++ b/api/metrics.py
@@ -22,8 +22,8 @@
infra/proto/src/chromiumos/metrics.proto output type.
Args:
- output_events: A chromiumos.MetricEvent protobuf message.
- prefix: A string to prepend to all metric event names.
+ output_events: A chromiumos.MetricEvent protobuf message.
+ prefix: A string to prepend to all metric event names.
"""
counters = collections.defaultdict(int)
counter_times = {}
diff --git a/api/router.py b/api/router.py
index 70bfc0e..d0388a2 100644
--- a/api/router.py
+++ b/api/router.py
@@ -165,11 +165,11 @@
"""Register the services from a generated proto module.
Args:
- proto_module: The generated proto module to register.
+ proto_module: The generated proto module to register.
Raises:
- ServiceModuleNotDefinedError when the service cannot be found in the
- provided module.
+ ServiceModuleNotDefinedError when the service cannot be found in the
+ provided module.
"""
services = proto_module.DESCRIPTOR.services_by_name
for service_name, svc in services.items():
@@ -225,21 +225,23 @@
"""Dispatch the request.
Args:
- service_name: The fully qualified service name.
- method_name: The name of the method being called.
- config: The call configs.
- input_handler: The request message handler.
- output_handlers: The response message handlers.
- config_handler: The config message handler.
+ service_name: The fully qualified service name.
+ method_name: The name of the method being called.
+ config: The call configs.
+ input_handler: The request message handler.
+ output_handlers: The response message handlers.
+ config_handler: The config message handler.
Returns:
- The return code.
+ The return code.
Raises:
- InvalidInputFileError when the input file cannot be read.
- InvalidOutputFileError when the output file cannot be written.
- ServiceModuleNotFoundError when the service module cannot be imported.
- MethodNotFoundError when the method cannot be retrieved from the module.
+ InvalidInputFileError when the input file cannot be read.
+ InvalidOutputFileError when the output file cannot be written.
+ ServiceModuleNotFoundError when the service module cannot be
+ imported.
+ MethodNotFoundError when the method cannot be retrieved from the
+ module.
"""
input_msg = self.get_input_message_instance(service_name, method_name)
input_handler.read_into(input_msg)
@@ -294,18 +296,19 @@
method_options: "google.protobuf.Message",
config: "api_config.ApiConfig",
) -> bool:
- """Check the chroot options, and execute assertion or note reexec as needed.
+ """Check the chroot options; execute assertion or note reexec as needed.
Args:
- service_options: The service options.
- method_options: The method options.
- config: The Build API call config instance.
+ service_options: The service options.
+ method_options: The method options.
+ config: The Build API call config instance.
Returns:
- True iff it needs to be reexeced inside the chroot.
+ True iff it needs to be reexeced inside the chroot.
Raises:
- cros_build_lib.DieSystemExit when the chroot setting cannot be satisfied.
+ cros_build_lib.DieSystemExit when the chroot setting cannot be
+ satisfied.
"""
if not config.run_endpoint:
# Do not enter the chroot for validate only and mock calls.
@@ -341,14 +344,14 @@
"""Re-execute the service inside the chroot.
Args:
- input_msg: The parsed input message.
- output_msg: The empty output message instance.
- config: The call configs.
- input_handler: Input message handler.
- output_handlers: Output message handlers.
- config_handler: Config message handler.
- service_name: The name of the service to run.
- method_name: The name of the method to run.
+ input_msg: The parsed input message.
+ output_msg: The empty output message instance.
+ config: The call configs.
+ input_handler: Input message handler.
+ output_handlers: Output message handlers.
+ config_handler: Config message handler.
+ service_name: The name of the service to run.
+ method_name: The name of the method to run.
"""
# Parse the chroot and clear the chroot field in the input message.
chroot = field_handler.handle_chroot(input_msg)
@@ -449,15 +452,16 @@
"""Get the implementation of the method for the service module.
Args:
- module_name: The name of the service module.
- method_name: The name of the method.
+ module_name: The name of the service module.
+ method_name: The name of the method.
Returns:
- The method.
+ The method.
Raises:
- MethodNotFoundError when the method cannot be found in the module.
- ServiceModuleNotFoundError when the service module cannot be imported.
+ MethodNotFoundError when the method cannot be found in the module.
+ ServiceModuleNotFoundError when the service module cannot be
+ imported.
"""
try:
module = importlib.import_module(
@@ -475,7 +479,7 @@
"""Register all the services.
Args:
- router: The router.
+ router: The router.
"""
router.Register(android_pb2)
router.Register(api_pb2)
diff --git a/api/router_unittest.py b/api/router_unittest.py
index 2c00e12..56324ec 100644
--- a/api/router_unittest.py
+++ b/api/router_unittest.py
@@ -197,11 +197,11 @@
"""Helper to create the implementation mock to test chroot assertions.
Args:
- expect_called: Whether the implementation should be called.
- When False, an assertion will fail if it is called.
+ expect_called: Whether the implementation should be called.
+ When False, an assertion will fail if it is called.
Returns:
- The implementation.
+ The implementation.
"""
def impl(_input_msg, _output_msg, _config):
diff --git a/api/validate.py b/api/validate.py
index b65e47b..2bfc075 100644
--- a/api/validate.py
+++ b/api/validate.py
@@ -26,11 +26,11 @@
"""Helper function to fetch the value of the field.
Args:
- field: The field name. Can be nested via . separation.
- message: The protobuf message it is being fetched from.
+ field: The field name. Can be nested via . separation.
+ message: The protobuf message it is being fetched from.
Returns:
- The value of the field.
+ The value of the field.
"""
if not field:
return message
@@ -54,8 +54,8 @@
"""Validate that the paths in |fields| exist.
Args:
- fields (str): The fields being checked. Can be . separated nested
- fields.
+ fields (str): The fields being checked. Can be . separated nested
+ fields.
"""
assert fields
@@ -83,8 +83,8 @@
"""Validate |field| is an element of |values|.
Args:
- field: The field being checked. May be . separated nested fields.
- values: The possible values field may take.
+ field: The field being checked. May be . separated nested fields.
+ values: The possible values field may take.
"""
assert field
assert values
@@ -117,11 +117,11 @@
"""Validate each |subfield| of the repeated |field| is in |values|.
Args:
- field: The field being checked. May be . separated nested fields.
- subfield: The field in the repeated |field| to validate, or None
- when |field| is not a repeated message, e.g. enum, scalars.
- values: The possible values field may take.
- optional: Also allow the field to be empty when True.
+ field: The field being checked. May be . separated nested fields.
+ subfield: The field in the repeated |field| to validate, or None
+ when |field| is not a repeated message, e.g. enum, scalars.
+ values: The possible values field may take.
+ optional: Also allow the field to be empty when True.
"""
assert field
assert values
@@ -168,7 +168,7 @@
and logging.
Args:
- description: Human readable description of the constraint
+ description: Human readable description of the constraint
"""
def decorator(func):
@@ -186,8 +186,8 @@
"""Validate all values of |field| pass a constraint.
Args:
- field: The field being checked. May be . separated nested fields.
- checkfunc: A constraint function to check on each value
+ field: The field being checked. May be . separated nested fields.
+ checkfunc: A constraint function to check on each value
"""
assert field
assert constraint
@@ -235,7 +235,7 @@
"""Verify |fields| have all been set to truthy values.
Args:
- fields: The fields being checked. May be . separated nested fields.
+ fields: The fields being checked. May be . separated nested fields.
"""
assert fields
@@ -262,7 +262,7 @@
"""Verify at least one of |fields| have been set.
Args:
- fields: The fields being checked. May be . separated nested fields.
+ fields: The fields being checked. May be . separated nested fields.
"""
assert fields
@@ -298,10 +298,10 @@
also have at least one entry.
Args:
- field: The repeated field being checked. May be . separated nested
- fields.
- subfields: The fields of the repeated message to validate.
- allow_empty: Also require at least one entry in the repeated field.
+ field: The repeated field being checked. May be . separated nested
+ fields.
+ subfields: The fields of the repeated message to validate.
+ allow_empty: Also require at least one entry in the repeated field.
"""
assert field
assert subfields
diff --git a/api/validate_unittest.py b/api/validate_unittest.py
index 1ab572f..4c0b8a9 100644
--- a/api/validate_unittest.py
+++ b/api/validate_unittest.py
@@ -120,10 +120,10 @@
"""Build a request instance, filling out the messages field.
Args:
- messages: Each messages data (id, name, flag, enum) as lists. Only
- requires as many as are set. e.g. _request([1], [2]) will create two
- messages with only ids set. _request([1, 'name']) will create one with
- id and name set, but not flag or enum.
+ messages: Each messages data (id, name, flag, enum) as lists. Only
+ requires as many as are set. e.g. _request([1], [2]) will create
+ two messages with only ids set. _request([1, 'name']) will
+ create one with id and name set, but not flag or enum.
"""
request = build_api_test_pb2.TestRequestMessage()
for message in messages or []: