Fixing imports in cli module (#8708)

While working on #8640, I realized that there were some hidden circular dependencies in certbot._internal.cli package. Then cerbot could break if the order of these imports changes.

This PR fixes that and apply isort on top of the result.
This commit is contained in:
Adrien Ferrand
2021-03-11 13:17:41 -08:00
committed by GitHub
parent 0962b0fc83
commit bc892e04c4
7 changed files with 61 additions and 87 deletions
+36 -50
View File
@@ -1,65 +1,51 @@
"""Certbot command line argument & config processing.""" """Certbot command line argument & config processing."""
# pylint: disable=too-many-lines # pylint: disable=too-many-lines
import argparse
import logging import logging
import logging.handlers import logging.handlers
import argparse
import sys import sys
from typing import Optional from typing import Optional
import certbot._internal.plugins.selection as plugin_selection
from certbot._internal.plugins import disco as plugins_disco
# pylint: disable=ungrouped-imports
import certbot import certbot
from certbot._internal import constants from certbot._internal import constants
from certbot._internal.cli.cli_constants import ARGPARSE_PARAMS_TO_REMOVE
import certbot.plugins.enhancements as enhancements from certbot._internal.cli.cli_constants import cli_command
from certbot._internal.cli.cli_constants import COMMAND_OVERVIEW
from certbot._internal.cli.cli_constants import DEPRECATED_OPTIONS
from certbot._internal.cli.cli_constants import ( from certbot._internal.cli.cli_constants import EXIT_ACTIONS
LEAUTO, from certbot._internal.cli.cli_constants import HELP_AND_VERSION_USAGE
old_path_fragment, from certbot._internal.cli.cli_constants import LEAUTO
new_path_prefix, from certbot._internal.cli.cli_constants import new_path_prefix
cli_command, from certbot._internal.cli.cli_constants import old_path_fragment
SHORT_USAGE, from certbot._internal.cli.cli_constants import SHORT_USAGE
COMMAND_OVERVIEW, from certbot._internal.cli.cli_constants import VAR_MODIFIERS
HELP_AND_VERSION_USAGE, from certbot._internal.cli.cli_constants import ZERO_ARG_ACTIONS
ARGPARSE_PARAMS_TO_REMOVE, from certbot._internal.cli.cli_utils import _Default
EXIT_ACTIONS, from certbot._internal.cli.cli_utils import _DeployHookAction
ZERO_ARG_ACTIONS, from certbot._internal.cli.cli_utils import _DomainsAction
VAR_MODIFIERS, from certbot._internal.cli.cli_utils import _EncodeReasonAction
DEPRECATED_OPTIONS from certbot._internal.cli.cli_utils import _PrefChallAction
) from certbot._internal.cli.cli_utils import _RenewHookAction
from certbot._internal.cli.cli_utils import _user_agent_comment_type
from certbot._internal.cli.cli_utils import ( from certbot._internal.cli.cli_utils import add_domains
_Default, from certbot._internal.cli.cli_utils import CaseInsensitiveList
read_file, from certbot._internal.cli.cli_utils import config_help
flag_default, from certbot._internal.cli.cli_utils import CustomHelpFormatter
config_help, from certbot._internal.cli.cli_utils import flag_default
HelpfulArgumentGroup, from certbot._internal.cli.cli_utils import HelpfulArgumentGroup
CustomHelpFormatter, from certbot._internal.cli.cli_utils import nonnegative_int
_DomainsAction, from certbot._internal.cli.cli_utils import parse_preferred_challenges
add_domains, from certbot._internal.cli.cli_utils import read_file
CaseInsensitiveList,
_user_agent_comment_type,
_EncodeReasonAction,
parse_preferred_challenges,
_PrefChallAction,
_DeployHookAction,
_RenewHookAction,
nonnegative_int
)
# These imports depend on cli_constants and cli_utils.
from certbot._internal.cli.verb_help import VERB_HELP, VERB_HELP_MAP
from certbot._internal.cli.group_adder import _add_all_groups from certbot._internal.cli.group_adder import _add_all_groups
from certbot._internal.cli.subparsers import _create_subparsers from certbot._internal.cli.helpful import HelpfulArgumentParser
from certbot._internal.cli.paths_parser import _paths_parser from certbot._internal.cli.paths_parser import _paths_parser
from certbot._internal.cli.plugins_parsing import _plugins_parsing from certbot._internal.cli.plugins_parsing import _plugins_parsing
from certbot._internal.cli.subparsers import _create_subparsers
# These imports depend on some or all of the submodules for cli. from certbot._internal.cli.verb_help import VERB_HELP
from certbot._internal.cli.helpful import HelpfulArgumentParser from certbot._internal.cli.verb_help import VERB_HELP_MAP
# pylint: enable=ungrouped-imports from certbot._internal.plugins import disco as plugins_disco
import certbot._internal.plugins.selection as plugin_selection
import certbot.plugins.enhancements as enhancements
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
+1 -1
View File
@@ -1,6 +1,6 @@
"""This module contains a function to add the groups of arguments for the help """This module contains a function to add the groups of arguments for the help
display""" display"""
from certbot._internal.cli import VERB_HELP from certbot._internal.cli.verb_help import VERB_HELP
def _add_all_groups(helpful): def _add_all_groups(helpful):
+14 -19
View File
@@ -11,35 +11,30 @@ from typing import Dict
import configargparse import configargparse
import zope.component import zope.component
import zope.interface import zope.interface
from zope.interface import interfaces as zope_interfaces from zope.interface import interfaces as zope_interfaces
from certbot import crypto_util from certbot import crypto_util
from certbot import errors from certbot import errors
from certbot import interfaces from certbot import interfaces
from certbot import util from certbot import util
from certbot.compat import os
from certbot._internal import constants from certbot._internal import constants
from certbot._internal import hooks from certbot._internal import hooks
from certbot._internal.cli.cli_constants import ARGPARSE_PARAMS_TO_REMOVE
from certbot._internal.cli.cli_constants import COMMAND_OVERVIEW
from certbot._internal.cli.cli_constants import EXIT_ACTIONS
from certbot._internal.cli.cli_constants import HELP_AND_VERSION_USAGE
from certbot._internal.cli.cli_constants import SHORT_USAGE
from certbot._internal.cli.cli_constants import ZERO_ARG_ACTIONS
from certbot._internal.cli.cli_utils import _Default
from certbot._internal.cli.cli_utils import add_domains
from certbot._internal.cli.cli_utils import CustomHelpFormatter
from certbot._internal.cli.cli_utils import flag_default
from certbot._internal.cli.cli_utils import HelpfulArgumentGroup
from certbot._internal.cli.verb_help import VERB_HELP
from certbot._internal.cli.verb_help import VERB_HELP_MAP
from certbot.compat import os
from certbot.display import util as display_util from certbot.display import util as display_util
from certbot._internal.cli import (
SHORT_USAGE,
CustomHelpFormatter,
flag_default,
VERB_HELP,
VERB_HELP_MAP,
COMMAND_OVERVIEW,
HELP_AND_VERSION_USAGE,
_Default,
add_domains,
EXIT_ACTIONS,
ZERO_ARG_ACTIONS,
ARGPARSE_PARAMS_TO_REMOVE,
HelpfulArgumentGroup
)
class HelpfulArgumentParser: class HelpfulArgumentParser:
"""Argparse Wrapper. """Argparse Wrapper.
@@ -1,10 +1,8 @@
"""This is a module that adds configuration to the argument parser regarding """This is a module that adds configuration to the argument parser regarding
paths for certificates""" paths for certificates"""
from certbot._internal.cli.cli_utils import config_help
from certbot._internal.cli.cli_utils import flag_default
from certbot.compat import os from certbot.compat import os
from certbot._internal.cli import (
flag_default,
config_help
)
def _paths_parser(helpful): def _paths_parser(helpful):
@@ -1,5 +1,5 @@
"""This is a module that handles parsing of plugins for the argument parser""" """This is a module that handles parsing of plugins for the argument parser"""
from certbot._internal.cli import flag_default from certbot._internal.cli.cli_utils import flag_default
def _plugins_parsing(helpful, plugins): def _plugins_parsing(helpful, plugins):
+5 -8
View File
@@ -1,14 +1,11 @@
"""This module creates subparsers for the argument parser""" """This module creates subparsers for the argument parser"""
from certbot import interfaces from certbot import interfaces
from certbot._internal import constants from certbot._internal import constants
from certbot._internal.cli.cli_utils import _EncodeReasonAction
from certbot._internal.cli import ( from certbot._internal.cli.cli_utils import _user_agent_comment_type
flag_default, from certbot._internal.cli.cli_utils import CaseInsensitiveList
read_file, from certbot._internal.cli.cli_utils import flag_default
CaseInsensitiveList, from certbot._internal.cli.cli_utils import read_file
_user_agent_comment_type,
_EncodeReasonAction
)
def _create_subparsers(helpful): def _create_subparsers(helpful):
+2 -4
View File
@@ -1,9 +1,7 @@
"""This module contain help information for verbs supported by certbot""" """This module contain help information for verbs supported by certbot"""
from certbot._internal.cli.cli_constants import SHORT_USAGE
from certbot._internal.cli.cli_utils import flag_default
from certbot.compat import os from certbot.compat import os
from certbot._internal.cli import (
SHORT_USAGE,
flag_default
)
# The attributes here are: # The attributes here are:
# short: a string that will be displayed by "certbot -h commands" # short: a string that will be displayed by "certbot -h commands"