def optmanager(): """Create a new OptionManager.""" option_manager = manager.OptionManager( prog='flake8', version='3.0.0', ) options.register_default_options(option_manager) return option_manager
def optmanager(): """Create a new OptionManager.""" prelim_parser = argparse.ArgumentParser(add_help=False) options.register_preliminary_options(prelim_parser) option_manager = manager.OptionManager( prog="flake8", version="3.0.0", parents=[prelim_parser], ) options.register_default_options(option_manager) return option_manager
def __init__(self, program='flake8-rst', version=__version__): self.start_time = time.time() self.end_time = None # type: float self.program = program self.version = version self.prelim_arg_parser = argparse.ArgumentParser(add_help=False) options.register_preliminary_options(self.prelim_arg_parser) # super(Application, self).__init__(program, version) doesn't work # because flake8 has hardcoded 'flake8' in this code snippet: self.option_manager = manager.OptionManager( prog=program, version=version, parents=[self.prelim_arg_parser], ) options.register_default_options(self.option_manager) self.check_plugins = None # type: plugin_manager.Checkers self.formatting_plugins = None # type: plugin_manager.ReportFormatters self.formatter = None # type: BaseFormatter self.guide = None # type: style_guide.StyleGuideManager self.file_checker_manager = None # type: checker.Manager self.options = None # type: argparse.Namespace self.args = None # type: List[str] self.result_count = 0 self.total_result_count = 0 self.catastrophic_failure = False self.running_against_diff = False self.parsed_diff = {} # type: Dict[str, Set[int]] self.option_manager.add_option( '--bootstrap', default=None, parse_from_config=True, help='Bootstrap code snippets. Useful for add imports.', ) self.option_manager.add_option( '--default-groupnames', default="*.rst->*: default", parse_from_config=True, help='Set default group names.', type='string', )
def __init__(self, program="flake8", version=flake8.__version__): """Initialize our application. :param str program: The name of the program/application that we're executing. :param str version: The version of the program/application we're executing. """ #: The timestamp when the Application instance was instantiated. self.start_time = time.time() #: The timestamp when the Application finished reported errors. self.end_time: Optional[float] = None #: The name of the program being run self.program = program #: The version of the program being run self.version = version #: The prelimary argument parser for handling options required for #: obtaining and parsing the configuration file. self.prelim_arg_parser = argparse.ArgumentParser(add_help=False) options.register_preliminary_options(self.prelim_arg_parser) #: The instance of :class:`flake8.options.manager.OptionManager` used #: to parse and handle the options and arguments passed by the user self.option_manager = manager.OptionManager( prog="flake8", version=flake8.__version__, parents=[self.prelim_arg_parser], ) options.register_default_options(self.option_manager) #: The instance of :class:`flake8.plugins.manager.Checkers` self.check_plugins: Optional[plugin_manager.Checkers] = None #: The instance of :class:`flake8.plugins.manager.ReportFormatters` self.formatting_plugins: Optional[ plugin_manager.ReportFormatters] = None #: The user-selected formatter from :attr:`formatting_plugins` self.formatter: Optional[BaseFormatter] = None #: The :class:`flake8.style_guide.StyleGuideManager` built from the #: user's options self.guide: Optional[style_guide.StyleGuideManager] = None #: The :class:`flake8.checker.Manager` that will handle running all of #: the checks selected by the user. self.file_checker_manager: Optional[checker.Manager] = None #: The user-supplied options parsed into an instance of #: :class:`argparse.Namespace` self.options: Optional[argparse.Namespace] = None #: The left over arguments that were not parsed by #: :attr:`option_manager` self.args: Optional[List[str]] = None #: The number of errors, warnings, and other messages after running #: flake8 and taking into account ignored errors and lines. self.result_count = 0 #: The total number of errors before accounting for ignored errors and #: lines. self.total_result_count = 0 #: Whether or not something catastrophic happened and we should exit #: with a non-zero status code self.catastrophic_failure = False #: Whether the program is processing a diff or not self.running_against_diff = False #: The parsed diff information self.parsed_diff: Dict[str, Set[int]] = {}
def __init__(self, program="flake8", version=flake8.__version__): # type: (str, str) -> None """Initialize our application. :param str program: The name of the program/application that we're executing. :param str version: The version of the program/application we're executing. """ #: The timestamp when the Application instance was instantiated. self.start_time = time.time() #: The timestamp when the Application finished reported errors. self.end_time = None #: The name of the program being run self.program = program #: The version of the program being run self.version = version #: The instance of :class:`flake8.options.manager.OptionManager` used #: to parse and handle the options and arguments passed by the user self.option_manager = manager.OptionManager( prog="flake8", version=flake8.__version__ ) options.register_default_options(self.option_manager) #: The preliminary options parsed from CLI before plugins are loaded, #: into a :class:`optparse.Values` instance self.prelim_opts = None #: The preliminary arguments parsed from CLI before plugins are loaded self.prelim_args = None #: The instance of :class:`flake8.options.config.ConfigFileFinder` self.config_finder = None #: The :class:`flake8.options.config.LocalPlugins` found in config self.local_plugins = None #: The instance of :class:`flake8.plugins.manager.Checkers` self.check_plugins = None #: The instance of :class:`flake8.plugins.manager.ReportFormatters` self.formatting_plugins = None #: The user-selected formatter from :attr:`formatting_plugins` self.formatter = None #: The :class:`flake8.style_guide.StyleGuideManager` built from the #: user's options self.guide = None #: The :class:`flake8.checker.Manager` that will handle running all of #: the checks selected by the user. self.file_checker_manager = None #: The user-supplied options parsed into an instance of #: :class:`optparse.Values` self.options = None #: The left over arguments that were not parsed by #: :attr:`option_manager` self.args = None #: The number of errors, warnings, and other messages after running #: flake8 and taking into account ignored errors and lines. self.result_count = 0 #: The total number of errors before accounting for ignored errors and #: lines. self.total_result_count = 0 #: Whether or not something catastrophic happened and we should exit #: with a non-zero status code self.catastrophic_failure = False #: Whether the program is processing a diff or not self.running_against_diff = False #: The parsed diff information self.parsed_diff = {}
def __init__(self, program='flake8', version=flake8.__version__): # type: (str, str) -> NoneType """Initialize our application. :param str program: The name of the program/application that we're executing. :param str version: The version of the program/application we're executing. """ #: The timestamp when the Application instance was instantiated. self.start_time = time.time() #: The timestamp when the Application finished reported errors. self.end_time = None #: The name of the program being run self.program = program #: The version of the program being run self.version = version #: The instance of :class:`flake8.options.manager.OptionManager` used #: to parse and handle the options and arguments passed by the user self.option_manager = manager.OptionManager( prog='flake8', version=flake8.__version__ ) options.register_default_options(self.option_manager) # We haven't found or registered our plugins yet, so let's defer # printing the version until we aggregate options from config files # and the command-line. First, let's clone our arguments on the CLI, # then we'll attempt to remove ``--version`` so that we can avoid # triggering the "version" action in optparse. If it's not there, we # do not need to worry and we can continue. If it is, we successfully # defer printing the version until just a little bit later. # Similarly we have to defer printing the help text until later. args = sys.argv[:] try: args.remove('--version') except ValueError: pass try: args.remove('--help') except ValueError: pass try: args.remove('-h') except ValueError: pass preliminary_opts, _ = self.option_manager.parse_known_args(args) # Set the verbosity of the program flake8.configure_logging(preliminary_opts.verbose, preliminary_opts.output_file) #: The instance of :class:`flake8.plugins.manager.Checkers` self.check_plugins = None #: The instance of :class:`flake8.plugins.manager.Listeners` self.listening_plugins = None #: The instance of :class:`flake8.plugins.manager.ReportFormatters` self.formatting_plugins = None #: The user-selected formatter from :attr:`formatting_plugins` self.formatter = None #: The :class:`flake8.plugins.notifier.Notifier` for listening plugins self.listener_trie = None #: The :class:`flake8.style_guide.StyleGuide` built from the user's #: options self.guide = None #: The :class:`flake8.checker.Manager` that will handle running all of #: the checks selected by the user. self.file_checker_manager = None #: The user-supplied options parsed into an instance of #: :class:`optparse.Values` self.options = None #: The left over arguments that were not parsed by #: :attr:`option_manager` self.args = None #: The number of errors, warnings, and other messages after running #: flake8 and taking into account ignored errors and lines. self.result_count = 0 #: The total number of errors before accounting for ignored errors and #: lines. self.total_result_count = 0 #: Whether or not something catastrophic happened and we should exit #: with a non-zero status code self.catastrophic_failure = False #: Whether the program is processing a diff or not self.running_against_diff = False #: The parsed diff information self.parsed_diff = {}
def __init__(self, program="flake8", version=flake8.__version__): """Initialize our application. :param str program: The name of the program/application that we're executing. :param str version: The version of the program/application we're executing. """ #: The timestamp when the Application instance was instantiated. self.start_time = time.time() #: The timestamp when the Application finished reported errors. self.end_time = None # type: float #: The name of the program being run self.program = program #: The version of the program being run self.version = version #: The instance of :class:`flake8.options.manager.OptionManager` used #: to parse and handle the options and arguments passed by the user self.option_manager = manager.OptionManager(prog="flake8", version=flake8.__version__) options.register_default_options(self.option_manager) #: The preliminary options parsed from CLI before plugins are loaded, #: into a :class:`optparse.Values` instance self.prelim_opts = None # type: optparse.Values #: The preliminary arguments parsed from CLI before plugins are loaded self.prelim_args = None # type: List[str] #: The instance of :class:`flake8.options.config.ConfigFileFinder` self.config_finder = None #: The :class:`flake8.options.config.LocalPlugins` found in config self.local_plugins = None # type: config.LocalPlugins #: The instance of :class:`flake8.plugins.manager.Checkers` self.check_plugins = None # type: plugin_manager.Checkers # fmt: off #: The instance of :class:`flake8.plugins.manager.ReportFormatters` self.formatting_plugins = None # type: plugin_manager.ReportFormatters # fmt: on #: The user-selected formatter from :attr:`formatting_plugins` self.formatter = None # type: BaseFormatter #: The :class:`flake8.style_guide.StyleGuideManager` built from the #: user's options self.guide = None # type: style_guide.StyleGuideManager #: The :class:`flake8.checker.Manager` that will handle running all of #: the checks selected by the user. self.file_checker_manager = None # type: checker.Manager #: The user-supplied options parsed into an instance of #: :class:`optparse.Values` self.options = None # type: optparse.Values #: The left over arguments that were not parsed by #: :attr:`option_manager` self.args = None # type: List[str] #: The number of errors, warnings, and other messages after running #: flake8 and taking into account ignored errors and lines. self.result_count = 0 #: The total number of errors before accounting for ignored errors and #: lines. self.total_result_count = 0 #: Whether or not something catastrophic happened and we should exit #: with a non-zero status code self.catastrophic_failure = False #: Whether the program is processing a diff or not self.running_against_diff = False #: The parsed diff information self.parsed_diff = {} # type: Dict[str, Set[int]]
def get_parser(): parser = manager.OptionManager(prog='ebb_lint_test', version='1') options.register_default_options(parser) EbbLint.add_options(parser) return parser, None