How to use _pylintrc_configure method in prospector

Best Python code snippet using prospector_python

__init__.py

Source:__init__.py Github

copy

Full Screen

...90 return errors91 def _error_message(self, filepath, message):92 location = Location(filepath, None, None, 0, 0)93 return Message('prospector', 'config-problem', location, message)94 def _pylintrc_configure(self, pylintrc, linter):95 errors = []96 linter.load_default_plugins()97 are_plugins_loaded = linter.config_from_file(pylintrc)98 if not are_plugins_loaded and hasattr(linter.config, 'load_plugins'):99 for plugin in linter.config.load_plugins:100 try:101 linter.load_plugin_modules([plugin])102 except ImportError:103 errors.append(104 self._error_message(105 pylintrc, "Could not load plugin %s" % plugin))106 return errors107 def configure(self, prospector_config, found_files):108 config_messages = []109 extra_sys_path = found_files.get_minimal_syspath()110 # create a list of packages, but don't include packages which are111 # subpackages of others as checks will be duplicated112 packages = [113 os.path.split(p)114 for p in found_files.iter_package_paths(abspath=False)115 ]116 packages.sort(key=len)117 check_paths = set()118 for package in packages:119 package_path = os.path.join(*package)120 if len(package) == 1:121 check_paths.add(package_path)122 continue123 for i in range(1, len(package)):124 if os.path.join(*package[:-i]) in check_paths:125 break126 else:127 check_paths.add(package_path)128 for filepath in found_files.iter_module_paths(abspath=False):129 package = os.path.dirname(filepath).split(os.path.sep)130 for i in range(0, len(package)):131 if os.path.join(*package[:i + 1]) in check_paths:132 break133 else:134 check_paths.add(filepath)135 check_paths = [found_files.to_absolute_path(p) for p in check_paths]136 # insert the target path into the system path to get correct behaviour137 self._orig_sys_path = sys.path138 # note: we prepend, so that modules are preferentially found in the139 # path given as an argument. This prevents problems where we are140 # checking a module which is already on sys.path before this141 # manipulation - for example, if we are checking 'requests' in a local142 # checkout, but 'requests' is already installed system wide, pylint143 # will discover the system-wide modules first if the local checkout144 # does not appear first in the path145 sys.path = list(extra_sys_path) + sys.path146 ext_found = False147 configured_by = None148 linter = ProspectorLinter(found_files)149 if prospector_config.use_external_config('pylint'):150 # try to find a .pylintrc151 pylint_options = prospector_config.tool_options('pylint')152 pylintrc = pylint_options.get('config_file')153 external_config = prospector_config.external_config_location('pylint')154 if pylintrc is None or external_config:155 pylintrc = external_config156 if pylintrc is None:157 pylintrc = find_pylintrc()158 if pylintrc is None:159 pylintrc_path = os.path.join(prospector_config.workdir,160 '.pylintrc')161 if os.path.exists(pylintrc_path):162 pylintrc = pylintrc_path163 if pylintrc is not None:164 # load it!165 configured_by = pylintrc166 ext_found = True167 self._args = linter.load_command_line_configuration(168 check_paths)169 config_messages += self._pylintrc_configure(pylintrc, linter)170 if not ext_found:171 linter.reset_options()172 self._args = linter.load_command_line_configuration(check_paths)173 config_messages = self._prospector_configure(174 prospector_config, linter)175 # Pylint 1.4 introduced the idea of explicitly specifying which176 # C-extensions to load. This is because doing so allows them to177 # execute any code whatsoever, which is considered to be unsafe.178 # The following option turns off this, allowing any extension to179 # load again, since any setup.py can execute arbitrary code and180 # the safety gained through this approach seems minimal. Leaving181 # it on means that the inference engine cannot do much inference182 # on modules with C-extensions which is a bit useless.183 linter.set_option('unsafe-load-any-extension', True)...

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