bgsdZddlZddlZddlmZddlmZddlmZddl m Z ddl m Z ddl mZejd ejZejd ejZejd Zd Zd diZdeefdZdeefdZdS)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+\)$cd}t}t|D]S\}}t|rd}t|r||dzT||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_file ignore_lines line_numberlines g/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/prospector/suppression.pyget_noqa_suppressionsr%s55L&}55.. T  % %d + + % $   # #D ) ) .   [1_ - - - l **z unused-import))pyflakesFL0001)frostedE101messagesct}td}|D]}|jdkr|jdkrt|j}|std|j|d}||j j }||j j  ||jdkr| |j j ||fS)Nc*ttSN)rlistrrz-_parse_pylint_informational..Ds D0A0Arpylintzsuppressed-messagez)Could not parsed suppressed message from r z file-ignored)r rsourcecode_PYLINT_SUPPRESSED_MESSAGEmatchmessagergrouplocationpathrappendr)r ignore_filesignore_messagesr)r(suppressed_code line_dicts r_parse_pylint_informationalr2Bs55L'(A(ABBO 8 8 >X % %|333388IIr23p_f_n3p3pqqq"'++a..+G,<,AB '*/077HHHH//  !1!6777  ((r filepathsc"t}tt}td}|D]} tj|d}nE#tj$r3}t j|jd|j tYd}~hd}~wwxYwt|\}} |r| |||xx| zcc<t|\} } || z}| D]\}} | D]g\} }|D]_}|||  d|f|tvr1t|D]#}|||  |$`h|||fS)z Given every message which was emitted by the tools, and the list of files to inspect, create a list of files to ignore, and a map of filepath -> line-number -> codes to ignore c*ttSr )rr r"rrr#z"get_suppressions..^s;s3C3Cr z: Nr$)r rr read_py_filesplitCouldNotHandleEncodingwarningswarnr, __cause__ ImportWarningrrr2items_PYLINT_EQUIVALENTS)r3rpaths_to_ignorelines_to_ignoremessages_to_ignorefilepathrerr ignore_filerpylint_ignore_filespylint_ignore_messagesrrcodesr& equivalents rget_suppressionsrJVs eeO',,O*+C+CDD 2 2 $1(;;AA$GGMM.    MSX8888- H H H HHHH  %:-$H$H! \  *    ) ) )!!!\1!!!!3Nh2W2W//**O06688RR$"&**,, R R K R R"8,[9==x>NOOO...&9$&?RR *84[AEEjQQQQ  R R O-? ??s'A  B"/)BB")__doc__rer: collectionsrpathlibrtypingr prospectorrprospector.exceptionsrprospector.messagercompile IGNORECASEr rr'rr?r2rJr"rrrUs?* ######::::::&&&&&& bj!5r}EEBJ{BM::'RZ(Z[[+++,)$w-))))(#@T #@#@#@#@#@#@r