Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
out = {
'ignore-paths': self.ignore_paths,
'ignore-patterns': self.ignore_patterns,
'output-format': self.output_format,
'output-target': self.output_target,
'autodetect': self.autodetect,
'uses': self.uses,
'max-line-length': self.max_line_length,
'member-warnings': self.member_warnings,
'doc-warnings': self.doc_warnings,
'test-warnings': self.test_warnings,
'strictness': self.strictness,
'requirements': self.requirements,
'python-targets': self.python_targets,
}
for tool in TOOLS.keys():
out[tool] = getattr(self, tool)
return out
def tool_names(self):
# TODO: this is currently a circular import, which is why it is not at the top of
# the module. However, there's no obvious way to get around this right now...
# pylint: disable=cyclic-import
from prospector.tools import TOOLS
return TOOLS.keys()
'tools': {
'flags': ['-t', '--tool'],
'help': 'A list of tools to run. This lets you set exactly which '
'tools to run. To add extra tools to the defaults, see '
'--with-tool. Possible values are: %s. By '
'default, the following tools will be run: %s' % (
', '.join(sorted(TOOLS.keys())),
', '.join(sorted(DEFAULT_TOOLS)),
),
},
'with_tools': {
'flags': ['-w', '--with-tool'],
'help': 'A list of tools to run in addition to the default tools. '
'To specify all tools explicitly, use the --tool argument. '
'Possible values are %s.' % (
', '.join(sorted(TOOLS.keys()))
),
},
'without_tools': {
'flags': ['-W', '--without-tool'],
'help': 'A list of tools that should not be run. Useful to turn off '
'only a single tool from the defaults. '
'To specify all tools explicitly, use the --tool argument. '
'Possible values are %s.' % (
', '.join(sorted(TOOLS.keys()))
),
},
'profiles': {
'flags': ['-P', '--profile'],
'help': 'The list of profiles to load. A profile is a certain'
)
parser.add_argument(
'-F', '--full-pep8', default=False, action='store_true',
help="Enables every PEP8 warning, so that all PEP8 style violations will be"
" reported."
)
tools_help = 'A list of tools to run. Possible values are: %s. By' \
' default, the following tools will be run: %s' % (
', '.join(sorted(tools.TOOLS.keys())),
', '.join(sorted(tools.DEFAULT_TOOLS))
)
parser.add_argument(
'-t', '--tools', default=None, nargs='+', help=tools_help,
choices=sorted(tools.TOOLS.keys())
)
parser.add_argument(
'-T', '--test-warnings', default=False, action='store_true',
help="Also check test modules and packages",
)
uses_help = 'A list of one or more libraries or frameworks that the' \
' project users. Possible values are django, celery. This will be' \
' autodetected by default, but if autotectection doesn\'t work,' \
' manually specify them using this flag.'
parser.add_argument(
'-u', '--uses', help=uses_help, default=[], nargs='+',
)
parser.add_argument(
def execute(self):
summary = {
'started': datetime.now(),
}
summary.update(self.config.get_summary_information())
found_files = find_python(self.config.ignores, self.config.paths,
self.config.explicit_file_mode, self.config.workdir)
# Run the tools
messages = []
for tool in self.config.get_tools(found_files):
for name, cls in tools.TOOLS.items():
if cls == tool.__class__:
toolname = name
break
else:
toolname = 'Unknown'
try:
# Tools can output to stdout/stderr in unexpected places, for example,
# pep257 emits warnings about __all__ and as pyroma exec's the setup.py
# file, it will execute any print statements in that, etc etc...
with capture_output(hide=not self.config.direct_tool_stdout) as capture:
messages += tool.run(found_files)
if self.config.include_tool_stdout:
loc = Location(self.config.workdir, None, None, None, None)
if profile.is_tool_enabled(tool):
to_run.add(tool)
else:
to_run = set(config.tools)
# profiles have no say in the list of tools run when
# a command line is specified
for tool in config.with_tools:
to_run.add(tool)
for tool in config.without_tools:
if tool in to_run:
to_run.remove(tool)
if config.tools is None and len(config.with_tools) == 0 and len(config.without_tools) == 0:
for tool in tools.TOOLS.keys():
enabled = profile.is_tool_enabled(tool)
if enabled is None:
enabled = tool in DEFAULT_TOOLS
if tool in to_run and not enabled:
to_run.remove(tool)
return sorted(list(to_run))
parser.add_argument(
'-8', '--no-style-warnings', default=False, action='store_true',
help="Don't create any warnings about style. This disables the PEP8 tool and"
" similar checks for formatting."
)
parser.add_argument(
'-F', '--full-pep8', default=False, action='store_true',
help="Enables every PEP8 warning, so that all PEP8 style violations will be"
" reported."
)
tools_help = 'A list of tools to run. Possible values are: %s. By' \
' default, the following tools will be run: %s' % (
', '.join(sorted(tools.TOOLS.keys())),
', '.join(sorted(tools.DEFAULT_TOOLS))
)
parser.add_argument(
'-t', '--tools', default=None, nargs='+', help=tools_help,
choices=sorted(tools.TOOLS.keys())
)
parser.add_argument(
'-T', '--test-warnings', default=False, action='store_true',
help="Also check test modules and packages",
)
uses_help = 'A list of one or more libraries or frameworks that the' \
' project users. Possible values are django, celery. This will be' \
' autodetected by default, but if autotectection doesn\'t work,' \
' manually specify them using this flag.'