From eba6a8fa0ba0ee2767885b8e5044b08b7f60498f Mon Sep 17 00:00:00 2001 From: Kenneth Daily Date: Wed, 18 Dec 2024 10:31:48 -0800 Subject: [PATCH] Run isort --- awscli/__init__.py | 2 +- awscli/__main__.py | 1 - awscli/alias.py | 6 +-- awscli/argparser.py | 1 - awscli/argprocess.py | 8 ++-- awscli/arguments.py | 7 +--- awscli/clidocs.py | 8 ++-- awscli/clidriver.py | 92 ++++++++++++++++++++++-------------------- awscli/compat.py | 30 +++++++------- awscli/errorhandler.py | 24 +++++------ awscli/formatter.py | 12 +++--- awscli/handlers.py | 80 +++++++++++++++++++----------------- awscli/help.py | 21 +++++----- awscli/paramfile.py | 4 +- awscli/plugin.py | 4 +- awscli/table.py | 6 +-- awscli/testutils.py | 36 ++++++++--------- awscli/topictags.py | 3 +- awscli/utils.py | 26 +++++++----- 19 files changed, 185 insertions(+), 186 deletions(-) diff --git a/awscli/__init__.py b/awscli/__init__.py index 93262db0e36d..fda8431a68c9 100644 --- a/awscli/__init__.py +++ b/awscli/__init__.py @@ -16,8 +16,8 @@ A Universal Command Line Environment for Amazon Web Services. """ -import os import importlib.abc +import os import sys __version__ = '2.22.12' diff --git a/awscli/__main__.py b/awscli/__main__.py index 7d49ba7f871c..63263a3cb831 100644 --- a/awscli/__main__.py +++ b/awscli/__main__.py @@ -16,6 +16,5 @@ from awscli.clidriver import main - if __name__ == "__main__": sys.exit(main()) diff --git a/awscli/alias.py b/awscli/alias.py index c5c70bd22bf2..affef7c87c9c 100644 --- a/awscli/alias.py +++ b/awscli/alias.py @@ -15,12 +15,10 @@ import shlex import subprocess -from botocore.configloader import raw_config_parse - -from awscli.compat import compat_shell_quote from awscli.commands import CLICommand +from awscli.compat import compat_shell_quote from awscli.utils import emit_top_level_args_parsed_event - +from botocore.configloader import raw_config_parse LOG = logging.getLogger(__name__) diff --git a/awscli/argparser.py b/awscli/argparser.py index bb0b7b2ec72f..5037443323c1 100644 --- a/awscli/argparser.py +++ b/awscli/argparser.py @@ -15,7 +15,6 @@ import sys from difflib import get_close_matches - HELP_BLURB = ( "To see help text, you can run:\n" "\n" diff --git a/awscli/argprocess.py b/awscli/argprocess.py index 454a6ad08a34..3498adfdaab1 100644 --- a/awscli/argprocess.py +++ b/awscli/argprocess.py @@ -12,18 +12,16 @@ # language governing permissions and limitations under the License. """Module for processing CLI args.""" -import os import logging +import os -from botocore.compat import OrderedDict, json - -from awscli import SCALAR_TYPES, COMPLEX_TYPES -from awscli import shorthand +from awscli import COMPLEX_TYPES, SCALAR_TYPES, shorthand from awscli.utils import ( find_service_and_method_in_event_name, is_document_type, is_document_type_container, ) +from botocore.compat import OrderedDict, json from botocore.utils import is_json_value_header LOG = logging.getLogger('awscli.argprocess') diff --git a/awscli/arguments.py b/awscli/arguments.py index 04e722ee064b..5e13e6f97ec5 100644 --- a/awscli/arguments.py +++ b/awscli/arguments.py @@ -39,13 +39,10 @@ import logging -from botocore import xform_name -from botocore.hooks import first_non_none_response - from awscli.argprocess import unpack_cli_arg from awscli.schema import SchemaTransformer -from botocore import model - +from botocore import model, xform_name +from botocore.hooks import first_non_none_response LOG = logging.getLogger('awscli.arguments') diff --git a/awscli/clidocs.py b/awscli/clidocs.py index 51e3b74d354c..d379a98f8c4f 100644 --- a/awscli/clidocs.py +++ b/awscli/clidocs.py @@ -13,9 +13,6 @@ import logging import os import re -from botocore import xform_name -from botocore.model import StringShape -from botocore.utils import is_json_value_header from awscli import SCALAR_TYPES from awscli.argprocess import ParamShorthandDocGen @@ -24,10 +21,13 @@ from awscli.utils import ( find_service_and_method_in_event_name, is_document_type, - operation_uses_document_types, is_streaming_blob_type, is_tagged_union_type, + operation_uses_document_types, ) +from botocore import xform_name +from botocore.model import StringShape +from botocore.utils import is_json_value_header LOG = logging.getLogger(__name__) EXAMPLES_DIR = os.path.join( diff --git a/awscli/clidriver.py b/awscli/clidriver.py index a1efe2c51f82..30938e9c524a 100644 --- a/awscli/clidriver.py +++ b/awscli/clidriver.py @@ -10,70 +10,76 @@ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. +import copy import json +import logging import os import platform -import sys -import copy -import logging import re +import sys import distro -import botocore.session -from botocore import xform_name -from botocore.compat import copy_kwargs, OrderedDict -from botocore.history import get_global_history_recorder -from botocore.configprovider import InstanceVarProvider -from botocore.configprovider import EnvironmentProvider -from botocore.configprovider import ScopedConfigProvider -from botocore.configprovider import ConstantProvider -from botocore.configprovider import ChainProvider +import botocore.session from awscli import __version__ +from awscli.alias import AliasCommandInjector, AliasLoader +from awscli.argparser import ( + ArgTableArgParser, + FirstPassGlobalArgParser, + MainArgParser, + ServiceArgParser, + SubCommandArgParser, +) +from awscli.argprocess import unpack_argument +from awscli.arguments import ( + BooleanArgument, + CLIArgument, + CustomArgument, + ListArgument, + UnknownArgumentError, +) +from awscli.autoprompt.core import AutoPromptDriver +from awscli.commands import CLICommand from awscli.compat import ( default_pager, get_stderr_text_writer, get_stdout_text_writer, ) +from awscli.constants import PARAM_VALIDATION_ERROR_RC +from awscli.errorhandler import ( + construct_cli_error_handlers_chain, + construct_entry_point_handlers_chain, +) from awscli.formatter import get_formatter -from awscli.plugin import load_plugins -from awscli.commands import CLICommand -from awscli.argparser import MainArgParser -from awscli.argparser import FirstPassGlobalArgParser -from awscli.argparser import ServiceArgParser -from awscli.argparser import ArgTableArgParser -from awscli.argparser import SubCommandArgParser -from awscli.help import ProviderHelpCommand -from awscli.help import ServiceHelpCommand -from awscli.help import OperationHelpCommand -from awscli.arguments import CustomArgument -from awscli.arguments import ListArgument -from awscli.arguments import BooleanArgument -from awscli.arguments import CLIArgument -from awscli.arguments import UnknownArgumentError -from awscli.argprocess import unpack_argument -from awscli.alias import AliasLoader -from awscli.alias import AliasCommandInjector +from awscli.help import ( + OperationHelpCommand, + ProviderHelpCommand, + ServiceHelpCommand, +) from awscli.logger import ( - set_stream_logger, - remove_stream_logger, - enable_crt_logging, disable_crt_logging, + enable_crt_logging, + remove_stream_logger, + set_stream_logger, ) +from awscli.plugin import load_plugins from awscli.utils import ( - add_metadata_component_to_user_agent_extra, + IMDSRegionProvider, + OutputStreamFactory, add_command_lineage_to_user_agent_extra, + add_metadata_component_to_user_agent_extra, + emit_top_level_args_parsed_event, ) -from awscli.utils import emit_top_level_args_parsed_event -from awscli.utils import OutputStreamFactory -from awscli.utils import IMDSRegionProvider -from awscli.constants import PARAM_VALIDATION_ERROR_RC -from awscli.autoprompt.core import AutoPromptDriver -from awscli.errorhandler import ( - construct_cli_error_handlers_chain, - construct_entry_point_handlers_chain, +from botocore import xform_name +from botocore.compat import OrderedDict, copy_kwargs +from botocore.configprovider import ( + ChainProvider, + ConstantProvider, + EnvironmentProvider, + InstanceVarProvider, + ScopedConfigProvider, ) - +from botocore.history import get_global_history_recorder LOG = logging.getLogger('awscli.clidriver') LOG_FORMAT = ( diff --git a/awscli/compat.py b/awscli/compat.py index e2acc638309a..887ed1cce7bc 100644 --- a/awscli/compat.py +++ b/awscli/compat.py @@ -6,31 +6,31 @@ # http://aws.amazon.com/apache2.0/ +import collections.abc as collections_abc +import contextlib +import io +import locale +import os +import os.path +import platform +import queue +import re +import shlex +import signal + # or in the "license" file accompanying this file. This file is # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. import sys -import re -import shlex -import os -import os.path -import platform +import urllib.parse as urlparse import zipfile -import signal -import contextlib -import collections.abc as collections_abc -import locale -import queue -import io -from urllib.request import urlopen from configparser import RawConfigParser from functools import partial -import urllib.parse as urlparse from urllib.error import URLError +from urllib.request import urlopen -from botocore.compat import six -from botocore.compat import OrderedDict +from botocore.compat import OrderedDict, six # Backwards compatible definitions from six PY3 = sys.version_info[0] == 3 diff --git a/awscli/errorhandler.py b/awscli/errorhandler.py index 1e7d70643576..7ac60221191a 100644 --- a/awscli/errorhandler.py +++ b/awscli/errorhandler.py @@ -13,29 +13,25 @@ import logging import signal -from botocore.exceptions import ( - NoRegionError, - NoCredentialsError, - ClientError, - ParamValidationError as BotocoreParamValidationError, -) - +from awscli.argparser import USAGE, ArgParseException from awscli.argprocess import ParamError, ParamSyntaxError from awscli.arguments import UnknownArgumentError -from awscli.argparser import ArgParseException, USAGE +from awscli.autoprompt.factory import PrompterKeyboardInterrupt from awscli.constants import ( - PARAM_VALIDATION_ERROR_RC, - CONFIGURATION_ERROR_RC, CLIENT_ERROR_RC, + CONFIGURATION_ERROR_RC, GENERAL_ERROR_RC, + PARAM_VALIDATION_ERROR_RC, ) -from awscli.utils import PagerInitializationException -from awscli.autoprompt.factory import PrompterKeyboardInterrupt from awscli.customizations.exceptions import ( - ParamValidationError, ConfigurationError, + ParamValidationError, +) +from awscli.utils import PagerInitializationException +from botocore.exceptions import ClientError, NoCredentialsError, NoRegionError +from botocore.exceptions import ( + ParamValidationError as BotocoreParamValidationError, ) - LOG = logging.getLogger(__name__) diff --git a/awscli/formatter.py b/awscli/formatter.py index ae346b624b9d..d0d191f210b4 100644 --- a/awscli/formatter.py +++ b/awscli/formatter.py @@ -13,16 +13,14 @@ import logging from datetime import datetime -from botocore.compat import json -from botocore.utils import set_value_from_jmespath -from botocore.paginate import PageIterator from ruamel.yaml import YAML -from awscli.table import MultiTable, Styler, ColorizedStyler -from awscli import text -from awscli import compat +from awscli import compat, text +from awscli.table import ColorizedStyler, MultiTable, Styler from awscli.utils import json_encoder - +from botocore.compat import json +from botocore.paginate import PageIterator +from botocore.utils import set_value_from_jmespath LOG = logging.getLogger(__name__) diff --git a/awscli/handlers.py b/awscli/handlers.py index e31de62b5634..ef3abe07fc3a 100644 --- a/awscli/handlers.py +++ b/awscli/handlers.py @@ -17,17 +17,15 @@ """ +from awscli.alias import register_alias_commands from awscli.argprocess import ParamShorthandParser -from awscli.customizations.ec2instanceconnect import ( - register_ec2_instance_connect_commands, -) -from awscli.paramfile import register_uri_param_handler from awscli.clidriver import no_pager_handler from awscli.customizations import datapipeline from awscli.customizations.addexamples import add_examples from awscli.customizations.argrename import register_arg_renames from awscli.customizations.assumerole import register_assume_role_provider from awscli.customizations.awslambda import register_lambda_create_function +from awscli.customizations.binaryformat import add_binary_formatter from awscli.customizations.cliinput import register_cli_input_args from awscli.customizations.cloudformation import ( initialize as cloudformation_init, @@ -50,44 +48,63 @@ ) from awscli.customizations.configservice.subscribe import register_subscribe from awscli.customizations.configure.configure import register_configure_cmd +from awscli.customizations.devcommands import register_dev_commands +from awscli.customizations.dlm.dlm import dlm_initialize +from awscli.customizations.dsql import register_dsql_customizations from awscli.customizations.dynamodb.ddb import register_ddb from awscli.customizations.dynamodb.paginatorfix import ( register_dynamodb_paginator_fix, ) -from awscli.customizations.history import register_history_mode -from awscli.customizations.history import register_history_commands from awscli.customizations.ec2.addcount import register_count_events from awscli.customizations.ec2.bundleinstance import register_bundleinstance from awscli.customizations.ec2.decryptpassword import ec2_add_priv_launch_key +from awscli.customizations.ec2.paginate import register_ec2_page_size_injector from awscli.customizations.ec2.protocolarg import register_protocol_args from awscli.customizations.ec2.runinstances import register_runinstances from awscli.customizations.ec2.secgroupsimplify import register_secgroup -from awscli.customizations.ec2.paginate import register_ec2_page_size_injector +from awscli.customizations.ec2instanceconnect import ( + register_ec2_instance_connect_commands, +) from awscli.customizations.ecr import register_ecr_commands from awscli.customizations.ecr_public import register_ecr_public_commands +from awscli.customizations.ecs import initialize as ecs_initialize +from awscli.customizations.eks import initialize as eks_initialize from awscli.customizations.emr.emr import emr_initialize from awscli.customizations.emrcontainers import ( initialize as emrcontainers_initialize, ) -from awscli.customizations.eks import initialize as eks_initialize -from awscli.customizations.ecs import initialize as ecs_initialize from awscli.customizations.gamelift import register_gamelift_commands from awscli.customizations.generatecliskeleton import ( register_generate_cli_skeleton, ) from awscli.customizations.globalargs import register_parse_global_args +from awscli.customizations.history import ( + register_history_commands, + register_history_mode, +) from awscli.customizations.iamvirtmfa import IAMVMFAWrapper -from awscli.customizations.iot import register_create_keys_and_cert_arguments -from awscli.customizations.iot import register_create_keys_from_csr_arguments +from awscli.customizations.iot import ( + register_create_keys_and_cert_arguments, + register_create_keys_from_csr_arguments, +) from awscli.customizations.iot_data import register_custom_endpoint_note +from awscli.customizations.kinesis import ( + register_kinesis_list_streams_pagination_backcompat, +) from awscli.customizations.kms import register_fix_kms_create_grant_docs -from awscli.customizations.dlm.dlm import dlm_initialize +from awscli.customizations.lightsail import initialize as lightsail_initialize +from awscli.customizations.logs import register_logs_commands from awscli.customizations.opsworks import initialize as opsworks_init +from awscli.customizations.opsworkscm import register_alias_opsworks_cm from awscli.customizations.paginate import register_pagination from awscli.customizations.putmetricdata import register_put_metric_data -from awscli.customizations.rds import register_rds_modify_split -from awscli.customizations.rds import register_add_generate_db_auth_token -from awscli.customizations.dsql import register_dsql_customizations +from awscli.customizations.quicksight import ( + register_quicksight_asset_bundle_customizations, +) +from awscli.customizations.rds import ( + register_add_generate_db_auth_token, + register_rds_modify_split, +) from awscli.customizations.rekognition import ( register_rekognition_detect_labels, ) @@ -95,36 +112,25 @@ from awscli.customizations.route53 import register_create_hosted_zone_doc_fix from awscli.customizations.s3.s3 import s3_plugin_initialize from awscli.customizations.s3errormsg import register_s3_error_msg -from awscli.customizations.timestampformat import register_timestamp_format +from awscli.customizations.s3events import ( + register_document_expires_string, + register_event_stream_arg, +) +from awscli.customizations.servicecatalog import ( + register_servicecatalog_commands, +) from awscli.customizations.sessendemail import register_ses_send_email +from awscli.customizations.sessionmanager import register_ssm_session from awscli.customizations.sso import register_sso_commands from awscli.customizations.streamingoutputarg import add_streaming_output_arg +from awscli.customizations.timestampformat import register_timestamp_format +from awscli.customizations.toplevelbool import register_bool_params from awscli.customizations.translate import ( register_translate_import_terminology, ) -from awscli.customizations.toplevelbool import register_bool_params from awscli.customizations.waiters import register_add_waiters -from awscli.customizations.opsworkscm import register_alias_opsworks_cm -from awscli.customizations.servicecatalog import ( - register_servicecatalog_commands, -) -from awscli.customizations.s3events import ( - register_event_stream_arg, - register_document_expires_string, -) -from awscli.customizations.sessionmanager import register_ssm_session -from awscli.customizations.logs import register_logs_commands -from awscli.customizations.devcommands import register_dev_commands from awscli.customizations.wizard.commands import register_wizard_commands -from awscli.customizations.binaryformat import add_binary_formatter -from awscli.customizations.lightsail import initialize as lightsail_initialize -from awscli.alias import register_alias_commands -from awscli.customizations.kinesis import ( - register_kinesis_list_streams_pagination_backcompat, -) -from awscli.customizations.quicksight import ( - register_quicksight_asset_bundle_customizations, -) +from awscli.paramfile import register_uri_param_handler def awscli_initialize(event_handlers): diff --git a/awscli/help.py b/awscli/help.py index 01a7e194950d..777b3f7dbcd0 100644 --- a/awscli/help.py +++ b/awscli/help.py @@ -12,28 +12,29 @@ # language governing permissions and limitations under the License. import logging import os -import sys import platform import shlex -from subprocess import Popen, PIPE +import sys +from subprocess import PIPE, Popen from docutils.core import publish_string from docutils.writers import manpage -from awscli.clidocs import ProviderDocumentEventHandler -from awscli.clidocs import ServiceDocumentEventHandler -from awscli.clidocs import OperationDocumentEventHandler -from awscli.clidocs import TopicListerDocumentEventHandler -from awscli.clidocs import TopicDocumentEventHandler +from awscli.argparser import ArgTableArgParser +from awscli.argprocess import ParamShorthandParser from awscli.bcdoc import docevents from awscli.bcdoc.restdoc import ReSTDocument from awscli.bcdoc.textwriter import TextWriter -from awscli.argprocess import ParamShorthandParser -from awscli.argparser import ArgTableArgParser +from awscli.clidocs import ( + OperationDocumentEventHandler, + ProviderDocumentEventHandler, + ServiceDocumentEventHandler, + TopicDocumentEventHandler, + TopicListerDocumentEventHandler, +) from awscli.topictags import TopicTagDB from awscli.utils import ignore_ctrl_c - LOG = logging.getLogger('awscli.help') diff --git a/awscli/paramfile.py b/awscli/paramfile.py index 3ee41836e788..92d9a0a809f3 100644 --- a/awscli/paramfile.py +++ b/awscli/paramfile.py @@ -10,12 +10,12 @@ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. +import copy import logging import os -import copy -from awscli.compat import compat_open from awscli import argprocess +from awscli.compat import compat_open logger = logging.getLogger(__name__) diff --git a/awscli/plugin.py b/awscli/plugin.py index 85cf3cd52042..46a26a4fc1a7 100644 --- a/awscli/plugin.py +++ b/awscli/plugin.py @@ -10,9 +10,9 @@ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. -import sys -import os import logging +import os +import sys from botocore.hooks import HierarchicalEmitter diff --git a/awscli/table.py b/awscli/table.py index 2426d936ec58..a60c9b0a8544 100644 --- a/awscli/table.py +++ b/awscli/table.py @@ -6,19 +6,19 @@ # http://aws.amazon.com/apache2.0/ +import struct + # or in the "license" file accompanying this file. This file is # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. import sys -import struct import unicodedata import colorama from awscli.utils import is_a_tty - # `autoreset` allows us to not have to sent reset sequences for every # string. `strip` lets us preserve color when redirecting. COLORAMA_KWARGS = { @@ -44,8 +44,8 @@ def get_text_length(text): def determine_terminal_width(default_width=80): # If we can't detect the terminal width, the default_width is returned. try: - from termios import TIOCGWINSZ from fcntl import ioctl + from termios import TIOCGWINSZ except ImportError: return default_width try: diff --git a/awscli/testutils.py b/awscli/testutils.py index 117e462f3883..a02ee9f8af76 100644 --- a/awscli/testutils.py +++ b/awscli/testutils.py @@ -20,37 +20,33 @@ """ -import os -import sys +import binascii +import contextlib import copy -import shutil -import time import json import logging -import tempfile -import platform -import contextlib -import binascii import math +import os +import platform +import shutil +import sys +import tempfile +import time +import unittest from pprint import pformat -from subprocess import Popen, PIPE +from subprocess import PIPE, Popen from unittest import mock -import unittest - -from awscli.compat import BytesIO, StringIO from ruamel.yaml import YAML -from botocore.session import Session -from botocore.exceptions import ClientError -from botocore.exceptions import WaiterError -import botocore.loaders -from botocore.awsrequest import AWSResponse - import awscli.clidriver -from awscli.plugin import load_plugins +import botocore.loaders from awscli.clidriver import CLIDriver - +from awscli.compat import BytesIO, StringIO +from awscli.plugin import load_plugins +from botocore.awsrequest import AWSResponse +from botocore.exceptions import ClientError, WaiterError +from botocore.session import Session _LOADER = botocore.loaders.Loader() INTEG_LOG = logging.getLogger('awscli.tests.integration') diff --git a/awscli/topictags.py b/awscli/topictags.py index 938ca641451b..fee934bd6924 100644 --- a/awscli/topictags.py +++ b/awscli/topictags.py @@ -19,8 +19,9 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. # -import os import json +import os + import docutils.core diff --git a/awscli/utils.py b/awscli/utils.py index 59cd99a507f3..d9b615c386eb 100644 --- a/awscli/utils.py +++ b/awscli/utils.py @@ -10,24 +10,28 @@ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. +import contextlib import csv -import signal import datetime -import contextlib +import logging import os import re +import signal import sys -from subprocess import Popen, PIPE -import logging +from subprocess import PIPE, Popen -from awscli.compat import get_stdout_text_writer -from awscli.compat import get_popen_kwargs_for_pager_cmd -from awscli.compat import StringIO -from botocore.useragent import UserAgentComponent -from botocore.utils import resolve_imds_endpoint_mode -from botocore.utils import IMDSFetcher -from botocore.utils import BadIMDSRequestError +from awscli.compat import ( + StringIO, + get_popen_kwargs_for_pager_cmd, + get_stdout_text_writer, +) from botocore.configprovider import BaseProvider +from botocore.useragent import UserAgentComponent +from botocore.utils import ( + BadIMDSRequestError, + IMDSFetcher, + resolve_imds_endpoint_mode, +) logger = logging.getLogger(__name__)