How to use _tool_not_available method in prospector

Best Python code snippet using prospector_python

__init__.py

Source:__init__.py Github

copy

Full Screen

...6from prospector.tools.pep257 import Pep257Tool7from prospector.tools.profile_validator import ProfileValidationTool8from prospector.tools.pyflakes import PyFlakesTool9from prospector.tools.pylint import PylintTool10def _tool_not_available(name, install_option_name):11 class NotAvailableTool(ToolBase):12 def run(self, _):13 raise FatalProspectorException(14 "\nCannot run tool %s as support was not installed.\n"15 "Please install by running 'pip install prospector[%s]'\n\n" % (name, install_option_name)16 )17 return NotAvailableTool18def _optional_tool(name, package_name=None, tool_class_name=None, install_option_name=None):19 package_name = "prospector.tools.%s" % (package_name or name)20 tool_class_name = tool_class_name or "%sTool" % name.title()21 install_option_name = install_option_name or ("with_%s" % name)22 try:23 tool_package = __import__(package_name, fromlist=[tool_class_name])24 except ImportError:25 tool_class = _tool_not_available(name, install_option_name)26 else:27 tool_class = getattr(tool_package, tool_class_name)28 return tool_class29TOOLS = {30 "dodgy": DodgyTool,31 "mccabe": McCabeTool,32 "pyflakes": PyFlakesTool,33 "pep8": Pep8Tool,34 "pylint": PylintTool,35 "pep257": Pep257Tool,36 "profile-validator": ProfileValidationTool,37 "frosted": _optional_tool("frosted"),38 "vulture": _optional_tool("vulture"),39 "pyroma": _optional_tool("pyroma"),...

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