.@ d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZ ddl
mZ ej d ej Z ej d
ej Z ej d Zd Zd
diZdee fdZdee fdZdS )aI
Each tool has its own method of ignoring errors and warnings.
For example, pylint requires a comment of the form
# pylint disable=
PEP8 will not warn on lines with
# noqa
Additionally, flake8 follows that convention for pyflakes errors,
but pyflakes itself does not.
Finally, an entire file is ignored by flake8 if this line is found
in the file:
# flake8\: noqa (the \ is needed to stop prospector ignoring this file :))
This module's job is to attempt to collect all of these methods into
a single coherent list of error suppression locations.
N)defaultdict)Path)List)encoding)FatalProspectorException)Messagezflake8[:=]\s*noqaz#\s+noqaz/^Suppressed \'([a-z0-9-]+)\' \(from line \d+\)$c d}t }t | D ]S\ }}t | rd}t | r| |dz T||fS )z
Finds all pep8/flake8 suppression messages
:param file_contents:
A list of file lines
:return:
A pair - the first is whether to ignore the whole file, the
second is a set of (0-indexed) line numbers to ignore.
FT )set enumerate_FLAKE8_IGNORE_FILEsearch_PEP8_IGNORE_LINEadd)
file_contentsignore_whole_fileignore_linesline_numberlines h/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/prospector/suppression.pyget_noqa_suppressionsr % s 55L&}55 . .T%%d++ % $##D)) .[1_---l** z
unused-import))pyflakesFL0001)frostedE101messagesc t }t d }| D ]}|j dk r|j dk rt |j }|st d|j | d }||j j
}||j j | |j dk r|
|j j
||fS )Nc * t t S N)r list r r z-_parse_pylint_informational..D s D0A0A r pylintzsuppressed-messagez)Could not parsed suppressed message from r
zfile-ignored)r r sourcecode_PYLINT_SUPPRESSED_MESSAGEmatchmessager grouplocationpathr appendr )r ignore_filesignore_messagesr) r( suppressed_code line_dicts r _parse_pylint_informationalr2 B s 55L'(A(ABBO 8 8>X%%|333 388II r23p_f_n3p3pqqq"'++a..+G,<,AB '*/077HHHH// !1!6777((r filepathsc " t }t t }t d }| D ]} t j | d }nE# t j $ r3}t
j |j d|j t Y d}~hd}~ww xY wt | \ }} |r| | ||xx | z cc<