From 663af7b50502b1aa7a6772408ba978b7210b6747 Mon Sep 17 00:00:00 2001 From: Zhiwei Liang Date: Tue, 8 Aug 2023 19:16:20 -0400 Subject: [PATCH] fix lint --- linodecli/arg_helpers.py | 4 ++-- linodecli/helpers.py | 6 +++++- linodecli/plugins/obj/__init__.py | 7 ++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/linodecli/arg_helpers.py b/linodecli/arg_helpers.py index 0de9b02b9..7e729ccce 100644 --- a/linodecli/arg_helpers.py +++ b/linodecli/arg_helpers.py @@ -16,7 +16,7 @@ from linodecli import plugins from .completion import bake_completions -from .helpers import pagination_args, register_args_shared +from .helpers import pagination_args_shared, register_args_shared def register_args(parser): @@ -121,7 +121,7 @@ def register_args(parser): "--debug", action="store_true", help="Enable verbose HTTP debug output." ) - pagination_args(parser) + pagination_args_shared(parser) register_args_shared(parser) return parser diff --git a/linodecli/helpers.py b/linodecli/helpers.py index ffbde3d05..c041ced65 100644 --- a/linodecli/helpers.py +++ b/linodecli/helpers.py @@ -63,7 +63,11 @@ def filter_markdown_links(text): return result -def pagination_args(parser: ArgumentParser): +def pagination_args_shared(parser: ArgumentParser): + """ + Add pagination related arguments to the given + ArgumentParser that may be shared across the CLI and plugins. + """ parser.add_argument( "--page", metavar="PAGE", diff --git a/linodecli/plugins/obj/__init__.py b/linodecli/plugins/obj/__init__.py index 6cb2a438b..d3d7a7625 100644 --- a/linodecli/plugins/obj/__init__.py +++ b/linodecli/plugins/obj/__init__.py @@ -22,7 +22,7 @@ from linodecli.cli import CLI from linodecli.configuration import _do_get_request from linodecli.configuration.helpers import _default_thing_input -from linodecli.helpers import expand_globs, pagination_args +from linodecli.helpers import expand_globs, pagination_args_shared from linodecli.plugins import PluginContext, inherit_plugin_args from linodecli.plugins.obj.buckets import create_bucket, delete_bucket from linodecli.plugins.obj.config import ( @@ -77,6 +77,7 @@ def flip_to_page(iterable: Iterable, page: int = 1): + """Given a iterable object and return a specific iteration (page)""" iterable = iter(iterable) for _ in range(page - 1): next(iterable) @@ -91,7 +92,7 @@ def list_objects_or_buckets( Lists buckets or objects """ parser = inherit_plugin_args(ArgumentParser(PLUGIN_BASE + " ls")) - pagination_args(parser) + pagination_args_shared(parser) parser.add_argument( "bucket", @@ -357,7 +358,7 @@ def list_all_objects( """ # this is for printing help when --help is in the args parser = inherit_plugin_args(ArgumentParser(PLUGIN_BASE + " la")) - pagination_args(parser) + pagination_args_shared(parser) parsed = parser.parse_args(args)