How to use die_on_tool_error method in prospector

Best Python code snippet using prospector_python

configuration.py

Source:configuration.py Github

copy

Full Screen

1# flake8: noqa2import setoptconf as soc3import pkg_resources4from prospector.config.datatype import OutputChoice5from prospector.formatters import FORMATTERS6from prospector.tools import DEFAULT_TOOLS, TOOLS7__all__ = ("build_manager",)8_VERSION = pkg_resources.get_distribution("prospector").version9def build_manager():10 manager = soc.ConfigurationManager("prospector")11 manager.add(soc.BooleanSetting("zero_exit", default=False))12 manager.add(soc.BooleanSetting("autodetect", default=True))13 manager.add(soc.ListSetting("uses", soc.String, default=[]))14 manager.add(soc.BooleanSetting("blending", default=True))15 manager.add(soc.BooleanSetting("doc_warnings", default=None))16 manager.add(soc.BooleanSetting("test_warnings", default=None))17 manager.add(soc.BooleanSetting("no_style_warnings", default=None))18 manager.add(soc.BooleanSetting("member_warnings", default=None))19 manager.add(soc.BooleanSetting("full_pep8", default=None))20 manager.add(soc.IntegerSetting("max_line_length", default=None))21 manager.add(soc.BooleanSetting("messages_only", default=False))22 manager.add(soc.BooleanSetting("summary_only", default=False))23 manager.add(24 soc.ListSetting(25 "output_format",26 OutputChoice(sorted(FORMATTERS.keys())),27 default=None,28 )29 )30 manager.add(soc.BooleanSetting("absolute_paths", default=False))31 manager.add(32 soc.ListSetting(33 "tools",34 soc.Choice(sorted(TOOLS.keys())),35 default=None,36 )37 )38 manager.add(soc.ListSetting("with_tools", soc.String, default=[]))39 manager.add(soc.ListSetting("without_tools", soc.String, default=[]))40 manager.add(soc.ListSetting("profiles", soc.String, default=[]))41 manager.add(soc.ListSetting("profile_path", soc.String, default=[]))42 manager.add(43 soc.ChoiceSetting(44 "strictness",45 ["veryhigh", "high", "medium", "low", "verylow"],46 default=None,47 )48 )49 manager.add(soc.BooleanSetting("show_profile", default=False))50 manager.add(soc.BooleanSetting("no_external_config", default=False))51 manager.add(soc.StringSetting("pylint_config_file", default=None))52 manager.add(soc.StringSetting("path", default=None))53 manager.add(soc.ListSetting("ignore_patterns", soc.String, default=[]))54 manager.add(soc.ListSetting("ignore_paths", soc.String, default=[]))55 manager.add(soc.BooleanSetting("die_on_tool_error", default=False))56 manager.add(soc.BooleanSetting("include_tool_stdout", default=False))57 manager.add(soc.BooleanSetting("direct_tool_stdout", default=False))58 return manager59def build_default_sources():60 sources = [61 build_command_line_source(),62 soc.EnvironmentVariableSource(),63 soc.ConfigFileSource(64 (65 ".prospectorrc",66 "setup.cfg",67 "tox.ini",68 )69 ),70 soc.ConfigFileSource(71 (72 soc.ConfigDirectory(".prospectorrc"),73 soc.HomeDirectory(".prospectorrc"),74 )75 ),76 ]77 return sources78def build_command_line_source(prog=None, description="Performs static analysis of Python code"):79 parser_options = {}80 if prog is not None:81 parser_options["prog"] = prog82 if description is not None:83 parser_options["description"] = description84 options = {85 "zero_exit": {86 "flags": ["-0", "--zero-exit"],87 "help": "Prospector will exit with a code of 1 (one) if any messages"88 " are found. This makes automation easier; if there are any"89 " problems at all, the exit code is non-zero. However this behaviour"90 " is not always desirable, so if this flag is set, prospector will"91 " exit with a code of 0 if it ran successfully, and non-zero if"92 " it failed to run.",93 },94 "autodetect": {95 "flags": ["-A", "--no-autodetect"],96 "help": "Turn off auto-detection of frameworks and libraries used."97 " By default, autodetection will be used. To specify"98 " manually, see the --uses option.",99 },100 "uses": {101 "flags": ["-u", "--uses"],102 "help": "A list of one or more libraries or frameworks that the"103 " project uses. Possible values are: django, celery, flask. This will be"104 " autodetected by default, but if autodetection doesn't"105 " work, manually specify them using this flag.",106 },107 "blending": {108 "flags": ["-B", "--no-blending"],109 "help": "Turn off blending of messages. Prospector will merge"110 " together messages from different tools if they represent"111 " the same error. Use this option to see all unmerged"112 " messages.",113 },114 "doc_warnings": {115 "flags": ["-D", "--doc-warnings"],116 "help": "Include warnings about documentation.",117 },118 "test_warnings": {119 "flags": ["-T", "--test-warnings"],120 "help": "Also check test modules and packages.",121 },122 "no_style_warnings": {123 "flags": ["-8", "--no-style-warnings"],124 "help": "Don't create any warnings about style. This disables the"125 " PEP8 tool and similar checks for formatting.",126 },127 "member_warnings": {128 "flags": ["-m", "--member-warnings"],129 "help": "Attempt to warn when code tries to access an attribute of a "130 "class or member of a module which does not exist. This is disabled "131 "by default as it tends to be quite inaccurate.",132 },133 "full_pep8": {134 "flags": ["-F", "--full-pep8"],135 "help": "Enables every PEP8 warning, so that all PEP8 style" " violations will be reported.",136 },137 "max_line_length": {138 "flags": ["--max-line-length"],139 "help": "The maximum line length allowed. This will be set by the strictness if no"140 " value is explicitly specified",141 },142 "messages_only": {143 "flags": ["-M", "--messages-only"],144 "help": "Only output message information (don't output summary" " information about the checks)",145 },146 "summary_only": {147 "flags": ["-S", "--summary-only"],148 "help": "Only output summary information about the checks (don't" "output message information)",149 },150 "output_format": {151 "flags": ["-o", "--output-format"],152 "help": "The output format. Valid values are: %s. This will output to stdout by default, however a target file can be used instead by adding :path-to-output-file, eg, -o json:output.json"153 % (", ".join(sorted(FORMATTERS.keys())),),154 },155 "absolute_paths": {156 "help": "Whether to output absolute paths when referencing files "157 "in messages. By default, paths will be relative to the "158 "project path",159 },160 "tools": {161 "flags": ["-t", "--tool"],162 "help": "A list of tools to run. This lets you set exactly which "163 "tools to run. To add extra tools to the defaults, see "164 "--with-tool. Possible values are: %s. By "165 "default, the following tools will be run: %s"166 % (167 ", ".join(sorted(TOOLS.keys())),168 ", ".join(sorted(DEFAULT_TOOLS)),169 ),170 },171 "with_tools": {172 "flags": ["-w", "--with-tool"],173 "help": "A list of tools to run in addition to the default tools. "174 "To specify all tools explicitly, use the --tool argument. "175 "Possible values are %s." % (", ".join(sorted(TOOLS.keys()))),176 },177 "without_tools": {178 "flags": ["-W", "--without-tool"],179 "help": "A list of tools that should not be run. Useful to turn off "180 "only a single tool from the defaults. "181 "To specify all tools explicitly, use the --tool argument. "182 "Possible values are %s." % (", ".join(sorted(TOOLS.keys()))),183 },184 "profiles": {185 "flags": ["-P", "--profile"],186 "help": "The list of profiles to load. A profile is a certain"187 " 'type' of behaviour for prospector, and is represented"188 " by a YAML configuration file. Either a full path to the YAML"189 " file describing the profile must be provided, or it must be"190 " on the profile path (see --profile-path)",191 },192 "profile_path": {193 "flags": ["--profile-path"],194 "help": "Additional paths to search for profile files. By default this"195 " is the path that prospector will check, and a directory "196 ' called ".prospector" in the path that prospector will check.',197 },198 "show_profile": {199 "flags": ["--show-profile"],200 "help": "Include the computed profile in the summary. This will show what"201 " prospector has decided the overall profile is once all profiles"202 " have been combined and inherited from. This will produce a large"203 " output in most cases so is only useful when trying to debug why"204 " prospector is not behaving like you expect.",205 },206 "strictness": {207 "flags": ["-s", "--strictness"],208 "help": "How strict the checker should be. This affects how"209 " harshly the checker will enforce coding guidelines. The"210 ' default value is "medium", possible values are'211 ' "veryhigh", "high", "medium", "low" and "verylow".',212 },213 "no_external_config": {214 "flags": ["-E", "--no-external-config"],215 "help": "Determines how prospector should behave when"216 " configuration already exists for a tool. By default,"217 " prospector will use existing configuration. This flag"218 " will cause prospector to ignore existing configuration"219 " and use its own settings for every tool. Note that"220 " prospector will always use its own config for tools which"221 " do not have custom configuration.",222 },223 "pylint_config_file": {224 "flags": ["--pylint-config-file"],225 "help": "The path to a pylintrc file to use to configure pylint. Prospector will find"226 " .pylintrc files in the root of the project, but you can use this option to "227 "specify manually where it is.",228 },229 "ignore_patterns": {230 "flags": ["-I", "--ignore-patterns"],231 "help": "A list of paths to ignore, as a list of regular"232 " expressions. Files and folders will be ignored if their"233 " full path contains any of these patterns.",234 },235 "ignore_paths": {236 "flags": ["-i", "--ignore-paths"],237 "help": "A list of file or directory names to ignore. If the"238 " complete name matches any of the items in this list, the"239 " file or directory (and all subdirectories) will be"240 " ignored.",241 },242 "die_on_tool_error": {243 "flags": ["-X", "--die-on-tool-error"],244 "help": "If a tool fails to run, prospector will try to carry on."245 " Use this flag to cause prospector to die and raise the"246 " exception the tool generated. Mostly useful for"247 " development on prospector.",248 },249 "include-tool-stdout": {250 "flags": ["--include-tool-stdout"],251 "help": "There are various places where tools will output warnings to "252 "stdout/stderr, which breaks parsing of JSON output. Therefore while tols "253 "is running, this is suppressed. For developing, it is sometimes useful to "254 "see this. This flag will cause stdout/stderr from a tool to be shown as "255 "a normal message amongst other warnings. See also --direct-tool-stdout",256 },257 "direct-tool-stdout": {258 "flags": ["--direct-tool-stdout"],259 "help": "Same as --include-tool-stdout, except the output will be printed "260 "directly rather than shown as a message.",261 },262 "path": {263 "flags": ["-p", "--path"],264 "help": "The path to a Python project to inspect. Defaults to PWD"265 " if not specified. Note: This command line argument is"266 " deprecated and will be removed in a future update. Please"267 " use the positional PATH argument instead.",268 },269 }270 positional = (271 (272 "checkpath",273 {274 "help": "The path to a Python project to inspect. Defaults to PWD"275 " if not specified. If multiple paths are specified,"276 " they must all be files (no directories).",277 "metavar": "PATH",278 "nargs": "*",279 },280 ),281 )282 return soc.CommandLineSource(283 options=options,284 version=_VERSION,285 parser_options=parser_options,286 positional=positional,...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...220 return tool.get("options", {})221 def external_config_location(self, tool_name):222 return getattr(self.config, "%s_config_file" % tool_name, None)223 @property224 def die_on_tool_error(self):225 return self.config.die_on_tool_error226 @property227 def summary_only(self):228 return self.config.summary_only229 @property230 def messages_only(self):231 return self.config.messages_only232 @property233 def blending(self):234 return self.config.blending235 @property236 def absolute_paths(self):237 return self.config.absolute_paths238 @property...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run prospector automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful