mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-04 12:16:53 +00:00
eliminate --bug-report double-parse quirk with store_true
This commit is contained in:
parent
03b33b9573
commit
52fb518104
5 changed files with 12 additions and 88 deletions
|
|
@ -1,6 +1,7 @@
|
|||
"""Module containing the application logic for Flake8."""
|
||||
import argparse
|
||||
import configparser
|
||||
import json
|
||||
import logging
|
||||
import sys
|
||||
import time
|
||||
|
|
@ -19,6 +20,7 @@ from flake8 import defaults
|
|||
from flake8 import exceptions
|
||||
from flake8 import style_guide
|
||||
from flake8 import utils
|
||||
from flake8.main import debug
|
||||
from flake8.main import options
|
||||
from flake8.options import aggregator
|
||||
from flake8.options import config
|
||||
|
|
@ -184,6 +186,11 @@ class Application:
|
|||
argv,
|
||||
)
|
||||
|
||||
if self.options.bug_report:
|
||||
info = debug.information(self.option_manager)
|
||||
print(json.dumps(info, indent=2, sort_keys=True))
|
||||
raise SystemExit(0)
|
||||
|
||||
if self.options.diff:
|
||||
LOG.warning(
|
||||
"the --diff option is deprecated and will be removed in a "
|
||||
|
|
|
|||
|
|
@ -1,36 +1,5 @@
|
|||
"""Module containing the logic for our debugging logic."""
|
||||
import argparse
|
||||
import json
|
||||
import platform
|
||||
from typing import Dict
|
||||
from typing import List
|
||||
|
||||
|
||||
class DebugAction(argparse.Action):
|
||||
"""argparse action to print debug information."""
|
||||
|
||||
def __init__(self, *args, option_manager, **kwargs):
|
||||
"""Initialize the action.
|
||||
|
||||
This takes an extra `option_manager` keyword argument which will be
|
||||
used to delay response.
|
||||
"""
|
||||
self._option_manager = option_manager
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def __call__(self, parser, namespace, values, option_string=None):
|
||||
"""Perform the argparse action for printing debug information."""
|
||||
# NOTE(sigmavirus24): Flake8 parses options twice. The first time, we
|
||||
# will not have any registered plugins. We can skip this one and only
|
||||
# take action on the second time we're called.
|
||||
if not self._option_manager.registered_plugins:
|
||||
return
|
||||
print(
|
||||
json.dumps(
|
||||
information(self._option_manager), indent=2, sort_keys=True
|
||||
)
|
||||
)
|
||||
raise SystemExit(0)
|
||||
|
||||
|
||||
def information(option_manager):
|
||||
|
|
@ -38,7 +7,6 @@ def information(option_manager):
|
|||
return {
|
||||
"version": option_manager.version,
|
||||
"plugins": plugins_from(option_manager),
|
||||
"dependencies": dependencies(),
|
||||
"platform": {
|
||||
"python_implementation": platform.python_implementation(),
|
||||
"python_version": platform.python_version(),
|
||||
|
|
@ -57,8 +25,3 @@ def plugins_from(option_manager):
|
|||
}
|
||||
for plugin in sorted(option_manager.registered_plugins)
|
||||
]
|
||||
|
||||
|
||||
def dependencies() -> List[Dict[str, str]]:
|
||||
"""Generate the list of dependencies we care about."""
|
||||
return []
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
"""Contains the logic for all of the default options for Flake8."""
|
||||
import argparse
|
||||
import functools
|
||||
|
||||
from flake8 import defaults
|
||||
from flake8.main import debug
|
||||
from flake8.options.manager import OptionManager
|
||||
|
||||
|
||||
|
|
@ -379,9 +377,6 @@ def register_default_options(option_manager: OptionManager) -> None:
|
|||
|
||||
add_option(
|
||||
"--bug-report",
|
||||
action=functools.partial(
|
||||
debug.DebugAction, option_manager=option_manager
|
||||
),
|
||||
nargs=0,
|
||||
action="store_true",
|
||||
help="Print information necessary when preparing a bug report",
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue