Best Python code snippet using prospector_python
suppression.py
Source:suppression.py
...43 ("pyflakes", "FL0001"),44 ("frosted", "E101"),45 )46}47def _parse_pylint_informational(messages):48 ignore_files = set()49 ignore_messages = defaultdict(lambda: defaultdict(list))50 for message in messages:51 if message.source == "pylint":52 if message.code == "suppressed-message":53 # this is a message indicating that a message was raised54 # by pylint but suppressed by configuration in the file55 match = _PYLINT_SUPPRESSED_MESSAGE.match(message.message)56 suppressed_code = match.group(1)57 line_dict = ignore_messages[message.location.path]58 line_dict[message.location.line].append(suppressed_code)59 elif message.code == "file-ignored":60 ignore_files.add(message.location.path)61 return ignore_files, ignore_messages62def get_suppressions(relative_filepaths, root, messages):63 """64 Given every message which was emitted by the tools, and the65 list of files to inspect, create a list of files to ignore,66 and a map of filepath -> line-number -> codes to ignore67 """68 paths_to_ignore = set()69 lines_to_ignore = defaultdict(set)70 messages_to_ignore = defaultdict(lambda: defaultdict(set))71 # first deal with 'noqa' style messages72 for filepath in relative_filepaths:73 abspath = os.path.join(root, filepath)74 try:75 file_contents = encoding.read_py_file(abspath).split("\n")76 except encoding.CouldNotHandleEncoding as err:77 # TODO: this output will break output formats such as JSON78 warnings.warn("{0}: {1}".format(err.path, err.cause), ImportWarning)79 continue80 ignore_file, ignore_lines = get_noqa_suppressions(file_contents)81 if ignore_file:82 paths_to_ignore.add(filepath)83 lines_to_ignore[filepath] |= ignore_lines84 # now figure out which messages were suppressed by pylint85 pylint_ignore_files, pylint_ignore_messages = _parse_pylint_informational(messages)86 paths_to_ignore |= pylint_ignore_files87 for filepath, line in pylint_ignore_messages.items():88 for line_number, codes in line.items():89 for code in codes:90 messages_to_ignore[filepath][line_number].add(("pylint", code))91 if code in _PYLINT_EQUIVALENTS:92 for equivalent in _PYLINT_EQUIVALENTS[code]:93 messages_to_ignore[filepath][line_number].add(equivalent)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!