
    e`0                       d dl mZ 	 d dlZd dlZdZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlZd dlmZ d dlmZmZ d dlmZmZ d dlmZmZmZmZmZmZmZmZm Z  d d	l!m"Z"m#Z#m$Z$ d d
l%m&Z& d dl'm(Z( erd dl)m*Z* dZ+ed   Z,ed   Z-ed   Z.ed   Z/ed   Z0ed   Z1e e,e-e.e/e0e1f   Z2 ede3e4ee5   ee5   eee5      ee4df         Z6e+df	 	 	 	 	 	 	 d+dZ7g dZ8d,dZ9d-dZ:d.dZ;d/dZ<	 d0	 	 	 	 	 	 	 d1dZ=	 d2	 	 	 	 	 	 	 d3dZ>d4dZ?d5d Z@d6d7d!ZAd8d"ZBd9d#ZCd:d$ZDd8d%ZEd;d&ZF	 d0	 	 	 	 	 	 	 	 	 d<d'ZGd=d(ZH G d) d*      ZIy# e$ r
 d dlZdZY =w xY w)>    )annotationsNTF)deque)IterableSequence)BufferedReaderBytesIO)	TYPE_CHECKINGAnyListLiteralPatternTextIOTupleTypeVarUnion)Modulemodutilsnodes)PY_EXTS)
OptionDict)PyLinterO   )zsuggestion-modezanalyse-fallback-blockszallow-global-unused-variables)zmax-line-lengthzdocstring-min-lengthzignored-modules)zno-docstring-rgxzdummy-variables-rgxzignored-argument-nameszmixin-class-rgx)zexclude-too-few-public-methodszignore-paths
py-versionT_GlobalOptionReturnTypes. c                R    dj                  t        j                  | |||            S )z'Wrap the text on the given line length.
)widthinitial_indentsubsequent_indent)jointextwrapwrap)textline_lenindents      4/usr/lib/python3/dist-packages/pylint/utils/utils.pynormalize_textr(   U   s*     996	
     )=-+c                    | |kD  | |k  z
  S N )abs     r'   cmpr2   d   s    Ea!er)   c                d    t        | |z
        }t        t        | |          |xr |dxs d }|S )zUGiven an old and new int value, return a string representing the
    difference.
    z.2fr   )absCMPSr2   )oldnewdiffdiff_strs       r'   diff_stringr:   h   s?     sSy>Ds3}%&t'=4*'C&DEHOr)   c                @   | j                         }dg }}|rWt        |t              r|j                  }n|j	                  t        |dd             	 |j                  j                         }|rW|j                          |dj                  |      fS # t        $ r Y .w xY w)z6Return the module name and the frame id in the module.r   namez<lambda>.)
frame
isinstancer   r<   appendgetattrparentAttributeErrorreverser!   )noder>   moduleobjs       r'   get_module_and_frameidrH   q   s    JJLEbCF
eV$ZZFJJwufj9:	LL&&(E  KKM388C=    		s   B 	BBc                *    |  d|t        |       z   dS )zgPermit to get a title formatted as ReStructuredText test (underlined with a
    chosen character).
    r   )len)title	characters     r'   get_rst_titlerM      s!     WBy3u:-.b11r)   c                `   d}| r|t        | d      z  }|rt        |      }|| dz  }|D ]  \  }}}|j                  d      }|d| dz  }|r't        |t              sJ t        |d      }	||	 d	z  }|sM|d
k7  sSt	        t        ||            }|d|j                  dd       dz  } |S )zHFormat an option's section using as a ReStructuredText formatted output.r   'z

help:z:
z  r&   r   r   z
  Default: ``z`` z```` ``z``
)rM   r(   getr?   str_format_option_valuereplace)
sectionoptionsdocresultformatted_docoptnameoptdictvaluehelp_optformatted_helps
             r'   get_rst_sectionra      s     F---
&s+]O4((#* 	N%;;v&AgYc""h,,,+HTBN(++FW,,We<=EeY(G'HMMF	N Mr)   c                    	 t        j                  |xs t        j                               } || |      S # t        $ r* t        j                  t        j                               }Y ;w xY wr.   )codecs	getreadersysgetdefaultencodingLookupError)streamencodingerrors
reader_clss       r'   decoding_streamrl      sa    
@%%h&J#2H2H2JK
 ff%%  @%%c&<&<&>?
@s   +6 0A)(A)c                    | j                         5 }|j                  }t        t        j                  |            cd d d        S # 1 sw Y   y xY wr.   )rh   readlinelisttokenize)rE   rh   rn   s      r'   tokenize_modulerq      s>    	 1&??H%%h/01 1 1s   *AAc                   i }t        j                  |      D ]  }t         j                  j                  |      \  }}||v s|dk(  r/|t        v r|dk7  sS|r?t         j                  j                  t         j                  j                  ||            s}|j                  d      r	 t        j                  t         j                  j                  ||            }t        |d      s|j                  |        d||<    y	# t        $ r Y t        $ r,}t        d| d| t        j                          Y d	}~#d	}~ww xY w)
zLoad all module and package in the given directory, looking for a
    'register' function in each one, used to register pylint checkers.
    __pycache____init__r=   register   zProblem importing module z: fileN)oslistdirpathsplitextr   isdirr!   
startswithr   load_module_from_filehasattrru   
ValueErrorImportErrorprintre   stderr)linter	directoryimportedfilenamebase	extensionrF   excs           r'   register_pluginsr      s    HJJy) '''**84i8t}4 
"GGMM"'',,y$"?@ ++C0'!77GGLLH5 6:.OOF+%&HTN3'"   V1(2cUC#**UUVs   (3D	E E !D;;E c                    | j                  |      D cg c]#  }|j                         s|j                         % c}S c c}w )a&  Return a list of stripped string by splitting the string given as
    argument on `sep` (',' by default), empty strings are discarded.

    >>> _splitstrip('a, b, c   ,  4,,')
    ['a', 'b', 'c', '4']
    >>> _splitstrip('a')
    ['a']
    >>> _splitstrip('a,
b,
c,')
    ['a', 'b', 'c']

    :type string: str or unicode
    :param string: a csv line

    :type sep: str or unicode
    :param sep: field separator, default to the comma (',')

    :rtype: str or unicode
    :return: the unquoted string (or the input string if it wasn't quoted)
    )splitstrip)stringsepwords      r'   _splitstripr      s/    ( &,\\#%6GT$**,DJJLGGGs   ??c                >    | s| S | d   dv r| dd } | d   dv r| dd } | S )zRemove optional quotes (simple or double) from the string.

    :param string: an optionally quoted string
    :return: the unquoted string (or the input string if it wasn't quoted)
    r   z"'rv   Nr/   )r   s    r'   _unquoter      s?     ayEbzUMr)   c                H    t        | t        t        f      r| S t        |       S r.   )r?   ro   tupler   )r^   s    r'   
_check_csvr      s     %$'ur)   c              #    K   t        | t        t        f      r| E d{    yt        dg      }d}| D ]q  }|dk(  rd}n	|dk(  r|rd}|dk(  r|s|j	                  d       -|d   ,|j                          |j	                  t        |g             ^|d   j	                  |       s d |D        E d{    y7 7 w)	zSplit a comma-separated list of regexps, taking care to avoid splitting
    a regex employing a comma as quantifier, as in `\d{1,2}`.NF{T},r   c              3  `   K   | ]&  }|dj                  |      j                          ( y w)Nr   )r!   r   ).0regexps     r'   	<genexpr>z$_check_regexp_csv.<locals>.<genexpr>  s&     XVEWBGGFO))+Xs   .$.)r?   ro   r   r   r@   pop)r^   regexpsopen_braceschars       r'   _check_regexp_csvr     s      %$' -24&M 	)Ds{"#s{;t$$udV}-""4(	) Y'XXX% 	$ 	Ys"   B>B:BB>4B<5B><B>c                    | j                         D cg c]  }|j                          }}d}d| dj                  |      z   S c c}w )zReturn string as a comment.r   # )
splitlinesr   r!   )r   linelinesr   s       r'   _commentr     sH    &,&7&7&9:dTZZ\:E:
CSE*//%((( ;s   Ac                ^     j                  dd      dk(  r#dj                  d |D              }t        |      S t        |t        t        f      r%dj                   fd|D              }t        |      S t        |t
              r1dj                  d |j                         D              }t        |      S t        |d	      r|j                  }t        |      S  j                  d      d
k(  r|rdnd}t        |      S t        |t              r|j                         rd| d}t        |      S )z|Return the user input's value from a 'compiled' value.

    TODO: Refactor the code to not use this deprecated function
    typeN
py_versionr=   c              3  2   K   | ]  }t        |        y wr.   )rT   )r   items     r'   r   z'_format_option_value.<locals>.<genexpr>'  s     5tT5s   r   c              3  6   K   | ]  }t        |        y wr.   )rU   )r   r   r]   s     r'   r   z'_format_option_value.<locals>.<genexpr>)  s     O-gt<Os   c              3  0   K   | ]  \  }}| d |   yw)rQ   Nr/   )r   kvs      r'   r   z'_format_option_value.<locals>.<genexpr>+  s     >1A3as>s   matchynyesnorO   )rS   r!   r?   ro   r   dictitemsr   patternrT   isspace)r]   r^   s   ` r'   rU   rU   !  s   
 {{64 L05u55 u: 
ED%=	)OOO u: 
E4	 >>> u: 
	 
 u:	 
V		$D u: 
E3	EMMOE7!u:r)   c                .   t        j                  dt        d       |rt        t	        |      |        t        d| d|        t        j
                         5  t        j                  dt               t        | |       d	d	d	       y	# 1 sw Y   y	xY w)
z0Format an option's section using the INI format.zEformat_section has been deprecated. It will be removed in pylint 4.0.   
stacklevelrw   []ignore)categoryN)warningswarnDeprecationWarningr   r   catch_warningsfilterwarnings_ini_format)rh   rW   rX   rY   s       r'   format_sectionr   6  sz     MMO
 hsm&)	AgYa.v&		 	 	" %3EFFG$% % %s   (BBc                   t        j                  dt        d       |D ]2  \  }}}d|v rt        |d   t              sJ d|d   v r)t        ||      }|j                  d      }|r9t        |t              sJ t        |d      }t        | 	       t        || 	       nt        | 	       |d
v rt        d| d| 	       t        |      j                         }t        j                  dt        |            rFddt        |      z  z   }|j                  d t        |      j                  d      D              }|dd }t        | d| | 	       5 y)z$Format options using the INI format.zB_ini_format has been deprecated. It will be removed in pylint 4.0.r   r   kwargs	new_namesrP   r   rR   rw   >   NoneFalse#r*   z^([\w-]+,)+[\w-]+$z
  c              3  &   K   | ]	  }|d z     yw)r   Nr/   )r   xs     r'   r   z_ini_format.<locals>.<genexpr>f  s     &N1q3w&Ns   r   Nr   )r   r   r   r?   r   rU   rS   rT   r(   r   r   rer   rJ   r!   r   )rh   rX   r\   r]   r^   r_   	separators          r'   r   r   J  sE   MML
 $+ 5%wgh/666gh//$We4;;v&h,,,%ht<Hv((v%%AgYa.v.J$$&Exx-s5z:!C#g,$66	!&NE
8H8H8M&NNcr
WIQug&V415r)   c                       e Zd ZdZddZddZy)IsortDriverzAA wrapper around isort API that changed between versions 4 and 5.c                    t         r;t        j                  j                  |j                  |j
                        | _        y t        j                  d|j                  |j
                        | _        y )N)extra_standard_libraryknown_third_partyr   )file_contentsknown_standard_libraryr   )	HAS_ISORT_5isortsettingsConfigr   r   isort5_configSortImports
isort4_obj)selfconfigs     r'   rt   zIsortDriver.__init__o  s^    !&!6!6
 (.'D'D"(":": "7 "D $// '-'D'D"(":":DOr)   c                    t         r*t        j                  j                  || j                        S | j
                  j                  |      S r.   )r   r   apiplace_moduler   r   )r   packages     r'   r   zIsortDriver.place_module  s7    99))'43E3EFF++G44r)   N)r   zargparse.Namespacereturnr   )r   rT   r   rT   )__name__
__module____qualname____doc__rt   r   r/   r)   r'   r   r   l  s    K$5r)   r   )r$   rT   r%   intr&   rT   r   rT   )r0   int | floatr1   r   r   r   )r6   r   r7   r   r   rT   )rE   znodes.NodeNGr   ztuple[str, str])rK   rT   rL   rT   r   rT   r.   )rW   
str | NonerX   !list[tuple[str, OptionDict, Any]]rY   r   r   rT   )strict)rh   zBufferedReader | BytesIOri   rT   rj   zLiteral['strict']r   zcodecs.StreamReader)rE   znodes.Moduler   zlist[tokenize.TokenInfo])r   r   r   rT   r   r   )r   )r   rT   r   rT   r   z	list[str])r   rT   r   rT   )r^   list[str] | tuple[str] | strr   zSequence[str])r^   r   r   zIterable[str])r]   r   r^   r
   r   rT   )
rh   r   rW   rT   rX   r   rY   r   r   r   )rh   r   rX   r   r   r   )J
__future__r   	isort.apir   isort.settingsr   r   argparserc   ry   r   re   r"   rp   r   collectionsr   collections.abcr   r   ior   r   typingr	   r
   r   r   r   r   r   r   r   astroidr   r   r   pylint.constantsr   pylint.typingr   pylint.lintr   DEFAULT_LINE_LENGTHGLOBAL_OPTION_BOOLGLOBAL_OPTION_INTGLOBAL_OPTION_LISTGLOBAL_OPTION_PATTERNGLOBAL_OPTION_PATTERN_LISTGLOBAL_OPTION_TUPLE_INTGLOBAL_OPTION_NAMESboolr   rT   r   r(   r5   r2   r:   rH   rM   ra   rl   rq   r   r   r   r   r   r   rU   r   r   r   r/   r)   r'   <module>r     sH  
 #K   	 	 
     . &
 
 
 , + $ $$  % 
 EF ./   %%UV !,/   $ICL	#s(O   3"
<? !"2 . 
 		8 !)	&$	&	& 	& 		&1'BH.Y2)2 	%%% /% 
	%
 
%(5D5 5A  Ks   
E EE