
    3 f                    &   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	Z	ddl
Z
ddlZddlmZ ddlmZ ddlmZ ej        dk     r+ e ee
dd                    r ee
j                  e
_        dZd	Zd
Z	 ej        dk    rej                            d          ZnCej                             ej        d          pej                            d          d          Zn# e$ r dZY nw xY wdZdZ dddZ!dZ"dZ#dddZ$dZ% e&g d          Z' e&ej(        dgz             e'z
  Z) e&g d          Z* e&g d          Z+e+,                    g d          Z- e&g d           Z. e&d!          Z/ e&e
j0        e
j1        g          Z1e1,                    e
j2        e
j3        g          Z4e4,                    e
j5        e
j6        g          Z7g d"Z8 ej9        d#          Z: ej9        d$          Z; ej9        d%          Z< ej9        d&          Z= ej9        d'          Z> ej9        d(          Z? ej9        d)          Z@ ej9        d*          ZA ej9        d+d,                    e)          z            ZB ej9        d-          ZC ej9        d.          ZD ej9        d/          ZE ej9        d0          ZF ej9        d1          ZG ej9        d2H                    d,                    d3 d4D                                           ZI ej9        d5          ZJ ej9        d6          ZKej        d7k    re
jL        ZLe
jM        ZMe
jN        ZNnd8xZLxZMZNi i i d9ZOd: ZPdd;ZQeQd<             ZReQd=             ZSeQd>             ZTeQd?             ZUeQd@             ZVdA ZWeQdB             ZXeQdC             ZYeQdD             ZZeQdE             Z[eQdF             Z\eQdG             Z]eQdH             Z^eQdI             Z_eQdJ             Z`eQdK             ZaeQdL             ZbeQdM             ZceQdN             ZdeQdO             ZeeQdP             ZfeQdQ             Zg e&dR           e&dS          z  ZhdT ZidU ZjeQdV             ZkeQdW             ZleQdX             ZmeQdY             ZneQdZ             ZoeQd[             ZpeQd\             ZqeQd]             ZreQd^             Zsd_ Ztd` Zu  eda           ej9        dbejv                  jw                  Zxdc Zydd ZzddfZ{ej|        fdgZ}ddiZ~dj Zdk Z G dl dm          Z G dn do          Z G dp dqe          Z G dr dse          Z G dt due          Z G dv dw          ZdefdxZdy Z	 	 dd{Zdd}Zd~ Zedk    r e             dS dS )a  
Check Python source code formatting, according to PEP 8.

For usage and a list of options, try this:
$ python pycodestyle.py -h

This program and its regression test suite live here:
https://github.com/pycqa/pycodestyle

Groups of errors and warnings:
E errors
W warnings
100 indentation
200 whitespace
300 blank lines
400 imports
500 line length
600 deprecation
700 statements
900 syntax error
    Nfnmatch)	lru_cache)OptionParser)   
   _compilez2.11.1z'.svn,CVS,.bzr,.hg,.git,__pycache__,.toxz&E121,E123,E126,E226,E24,E704,W503,W504win32z~\.pycodestyleXDG_CONFIG_HOMEz	~/.configpycodestyle)z	setup.cfgztox.iniO         )	top_levelmethodH      z+%(path)s:%(row)d:%(col)d: %(code)s %(text)sz%%(path)s:%(row)d: [%(code)s] %(text)s)defaultpylinti   )FalseNoneTrueprint)>>***+-)r   r   /z//r   r   @)^&|z<<r   %)z**=z*=z/=z//=z+=z-=z!=<>z%=z^=z&=z|===z<=z>=z<<=z>>==andinisorz->:=u    	 )directoriesfileslogical linesphysical linesz([ \t]*)z\b[A-Z]\d{3}\bz	u?r?["\']z[\[({][ \t]|[ \t][\]}),;:](?!=)z[,;:]\s*(?:  |\t)z?(\bNone|\bFalse|\bTrue)?\s*([=!]=)\s*(?(1)|(None|False|True))\bz*\b(?<!is\s)(not)\s+[^][)(}{ ]+\s+(in|is)\szU[=!]=\s+type(?:\s*\(\s*([^)]*[^ )])\s*\))|\btype(?:\s*\(\s*([^)]*[^ )])\s*\))\s+[=!]=z(\s*)\b(?:%s)\b(\s*)r#   z*(?:[^,\s])(\s*)(?:[-+*/|!<=>%&^]+|:=)(\s*)z
\blambda\bz*^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$z^(async\s+def|def)\bz#^(async\s+def\s+|def\s+|class\s+|@)z
^\s*({})\bc              #   B   K   | ]}|                     d d          V  dS ) z\s+N)replace).0ss     A/var/www/equiseq/venv/lib/python3.11/site-packages/pycodestyle.py	<genexpr>r8      s@       " "Q!))C"8"8 " " " " " "    )defz	async defforz	async forifelifelsetryexceptfinallywithz
async withclasswhilez-^__([^\s]+)__(?::\s*[a-zA-Z.0-9_\[\]\"]+)? = z
except\s*:)r      )physical_linelogical_linetreec                 l    d t          j        |           j                                        D             S )Nc                 <    g | ]}|j         |j        k    |j        S  )kindPOSITIONAL_OR_KEYWORDname)r5   	parameters     r7   
<listcomp>z#_get_parameters.<locals>.<listcomp>   s:     B B B~!@@@ N A@@r9   )inspect	signature
parametersvalues)functions    r7   _get_parametersrW      sC    B B **5<<>>B B B Br9   c                 b   d }t          j        |           rSt          |           }|rA|d         dv r7|!t                              | j        pd          } || |d         ||           nDt          j        |           r0t          | j                  dd         ddgk    r || d|d           | S )	zRegister a new check object.c                     | t           |         v r0t           |         |          d                             |pg            d S |pdg|ft           |         | <   d S )Nr    )_checksextend)checkrM   codesargss       r7   
_add_checkz"register_check.<locals>._add_check   s\    GDM!!DM% #**5;B77777$)MbT4#8GDM%   r9   r   )rG   rH   NrZ   r   selfrI   )rR   
isfunctionrW   ERRORCODE_REGEXfindall__doc__isclass__init__)r]   r^   r`   r_   s       r7   register_checkrh      s    9 9 9
 %   3u%% 	4DG@@@}'//0CDDJud1gud333			 35>**2A2.662BBBJufeT222Lr9   c                     t                               |                               d          }t          |          D ]\  }}||k    r|dfc S dS )a  Never mix tabs and spaces.

    The most popular way of indenting Python is with spaces only.  The
    second-most popular way is with tabs only.  Code indented with a
    mixture of tabs and spaces should be converted to using spaces
    exclusively.  When invoking the Python command line interpreter with
    the -t option, it issues warnings about code that illegally mixes
    tabs and spaces.  When using -tt these warnings become errors.
    These options are highly recommended!

    Okay: if a == 0:\n    a = 1\n    b = 1
    r   z/E101 indentation contains mixed spaces and tabsN)INDENT_REGEXmatchgroup	enumerate)rG   indent_charindentoffsetchars        r7   tabs_or_spacesrr      sp     ..44Q77F!&)) M M;LLLLL M Mr9   c                     t                               |                               d          }d|v r|                    d          dfS dS )zOn new projects, spaces-only are strongly recommended over tabs.

    Okay: if True:\n    return
    W191: if True:\n\treturn
    r   	zW191 indentation contains tabsN)rj   rk   rl   index)rG   ro   s     r7   tabs_obsoleterv      sM     ..44Q77Fv~~||D!!#CCC ~r9   c                     |                      d          } |                      d          } |                      d          } |                      d          }| |k    r|rt          |          dfS dS dS )a  Trailing whitespace is superfluous.

    The warning returned varies on whether the line itself is blank,
    for easier filtering for those who want to indent their blank lines.

    Okay: spam(1)\n#
    W291: spam(1) \n#
    W293: class Foo(object):\n    \n    bang = 12
    
z 	zW291 trailing whitespace)r   z#W293 blank line contains whitespaceNrstriplen)rG   strippeds     r7   trailing_whitespacer      s     "((..M!((..M!((00M##G,,H   	<x=="<<<;;	 ! r9   c                     ||k    r8|                      d          }| r|sdS || k    rt          |d                   dfS dS dS )zTrailing blank lines are superfluous.

    Okay: spam(1)
    W391: spam(1)\n

    However the last line should end with a new line (warning W292).
    
)r   zW391 blank line at end of filerF   zW292 no newline at end of fileNr{   )rG   linesline_numbertotal_linesstripped_last_lines        r7   trailing_blank_linesr      sj     k!!*11&99 	7!3 	766..uRy>>#CCC "! /.r9   c                    |                                  }t          |          }||k    r|s|dk    r|                    d          rdS |                                }t          |          dk    r|st          |          dk    r:|d         dk    r.t          |          t          |d                   z
  |dz
  k     rdS ||k    r|d	||fz  fS dS dS dS )
a  Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.

    Reports error E501.
    r   #!Nr   r   #rF      z'E501 line too long (%d > %d characters))r|   r}   
startswithsplit)rG   max_line_length	multiliner   noqalinelengthchunkss           r7   maximum_line_lengthr     s    !!DYYF! 5 5F [[A)[[A&)s"2"2D		Cr
OO+o.AAAFO### &+.4o-F&G H H   $#r9   c                 P   t                               |           sdS |dz
  }|dk     rd}nt          ||dz
                     }||k    rdS |t          |          k     rb||                                         }|                    d          st                               |          rn|dz  }|t          |          k     bdS |dz   }|t          |          k     r3||                                         rn|dz  }|t          |          k     3dS t          ||                   |k    S )NFr   r   r    T)STARTSWITH_TOP_LEVEL_REGEXrk   expand_indentr}   stripr   )rH   indent_levelr   r   line_idxprev_indentr   next_idxs           r7   _is_one_linerr   -  sA   %++L99 uQH!||#E(Q,$788\!!u
SZZ

X$$&&s## 	(B(H(H(N(N 	MH SZZ

 u!|H
SZZ

?  "" 	MH	 SZZ

 tx))\99r9   c	              #   p  K   t           d         }	t           d         }
|s||	k     rdS |                    d          r
|rdV  dS dS ||	k    s|r||
dz   k    rdd|z  fV  dS t                              |           rt	          | |||          r|dk    rdS |r||
k    s||k     st
                              |          s|}d	}|||	z
  dd
         D ]n}|                                rXt          |          |k     rEt          |          }t                              |	                                          }|s|dk    r no|rdd|
dfV  dS dd
                    |
          fV  dS dS dS dS ||	k    rdd|	|fz  fV  dS dS | r*|s*||	k    r&|                    d          rdd|	|fz  fV  dS dS dS dS dS )aO  Separate top-level function and class definitions with two blank
    lines.

    Method definitions inside a class are separated by a single blank
    line.

    Extra blank lines may be used (sparingly) to separate groups of
    related functions.  Blank lines may be omitted between a bunch of
    related one-liners (e.g. a set of dummy implementations).

    Use blank lines in functions, sparingly, to indicate logical
    sections.

    Okay: def a():\n    pass\n\n\ndef b():\n    pass
    Okay: def a():\n    pass\n\n\nasync def b():\n    pass
    Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
    Okay: default = 1\nfoo = 1
    Okay: classify = 1\nfoo = 1

    E301: class Foo:\n    b = 0\n    def bar():\n        pass
    E302: def a():\n    pass\n\ndef b(n):\n    pass
    E302: def a():\n    pass\n\nasync def b(n):\n    pass
    E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
    E303: def a():\n\n\n\n    pass
    E304: @decorator\n\ndef a():\n    pass
    E305: def a():\n    pass\na()
    E306: def a():\n    def b():\n        pass\n    def c():\n        pass
    r   r   Nr    )r   z/E304 blank lines found after function decoratorr   r   zE303 too many blank lines (%d)FrF   zE306 expected z/ blank line before a nested definition, found 0z$E301 expected {} blank line, found 0z&E302 expected %s blank lines, found %d)zdef zclass zIE305 expected %s blank lines after class or function definition, found %d)BLANK_LINES_CONFIGr   r   rk   r   DOCSTRING_REGEXr   r   STARTSWITH_DEF_REGEXlstripformat)rH   blank_linesr   r   blank_beforeprevious_logical previous_unindented_logical_lineprevious_indent_levelr   top_level_linesmethod_linesancestor_levelnestedr   s                 r7   r   r   P  s     B )5O%h/L  > >""3'' -/ 	GFFFFFF	G 	G

'
' ()\A-===1K???????	#	)	),	7	7 &/ ,e[II	AF 	/ L00)L88#))*:;; 9 ". "+"?"C"CD " "Dzz|| "d(;(;n(L(L)6t)<)<!5!;!;DKKMM!J!J! "^q%8%8!E &!8DG G G G G G G CJJ$& & & & & & & &% 108888& _,,=A/ / / / / / / / -,  //O++,778JKK ,  58// / 	/ 	/ 	/ 	/ 	// / / /++++r9   c              #   T  K   | }t                               |          D ]}|                                }|                                }|                                }|d                                         r|dz   d|z  fV  e||dz
           dk    r|dv rdnd}|| d| d	fV  d
S )aH  Avoid extraneous whitespace.

    Avoid extraneous whitespace in these situations:
    - Immediately inside parentheses, brackets or braces.
    - Immediately before a comma, semicolon, or colon.

    Okay: spam(ham[1], {eggs: 2})
    E201: spam( ham[1], {eggs: 2})
    E201: spam(ham[ 1], {eggs: 2})
    E201: spam(ham[1], { eggs: 2})
    E202: spam(ham[1], {eggs: 2} )
    E202: spam(ham[1 ], {eggs: 2})
    E202: spam(ham[1], {eggs: 2 })

    E203: if x == 4: print x, y; x, y = y , x
    E203: if x == 4: print x, y ; x, y = y, x
    E203: if x == 4 : print x, y; x, y = y, x
    rF   r   zE201 whitespace after '%s',}])E202E203z whitespace before ''N)EXTRANEOUS_WHITESPACE_REGEXfinditerrl   r   startisspace)rH   r   rk   textrq   foundcodes          r7   extraneous_whitespacer     s      ( D,55d;; 	> 	>{{}}zz||8 	>!)9D@@@@@@%!)_##"emmFFDD==d=======	> 	>r9   c              #     K   t                               |           D ]}|                                \  }}d|v r|                    d          dfV  n,t	          |          dk    r|                    d          dfV  d|v r|                    d          dfV  t	          |          dk    r|                    d          dfV  dS )	zAvoid extraneous whitespace around keywords.

    Okay: True and False
    E271: True and  False
    E272: True  and False
    E273: True and\tFalse
    E274: True\tand False
    rt   r   zE274 tab before keywordz#E272 multiple spaces before keywordr   zE273 tab after keywordz"E271 multiple spaces after keywordN)KEYWORD_REGEXr   groupsr   r}   rH   rk   beforeafters       r7   whitespace_around_keywordsr     s       ''55 G G6>>++a..";;;;;;[[1__++a.."GGGGG5==++a.."::::::ZZ!^^++a.."FFFFFG Gr9   c              #   ^  K   t          ||dd                   D ]\  }}|j        |j        k    r||j        t          j        k    rgt          j        |j                  rN|j        t          vr@|j        dk    r|j        dk    s*|j        dk    r|j        dk    s|j        dvr|j        dfV  dS )	zKeywords should be followed by whitespace.

    Okay: from foo import (bar, baz)
    E275: from foo import(bar, baz)
    E275: from importable.module import(bar, baz)
    E275: if(foo): bar
    r   Nr@   r   yield)z:
z%E275 missing whitespace after keyword)
zipendr   typetokenizeNAMEkeyword	iskeywordstring
SINGLETONS)rH   tokenstok0tok1s       r7    missing_whitespace_after_keywordr     s       &&*-- D D
d H
""	X]**!$+.. +:--[H,,1C1C[G++s0B0B5(((CCCCCD Dr9   c              #   4  K   | rdnd}| rdnd}||z  rd|d|z   dt          |          z   fz  fV  |                    d          }|r||k    rd|d|z   d	fz  fV  n|s||k    rd|d|z   d
fz  fV  |r |dk    rdnd}	||	z   }
||
k    rd|dz  fV  dS dS dS )a  Use indent_size (PEP8 says 4) spaces per indentation level.

    For really old code that you don't want to mess up, you can continue
    to use 8-space tabs.

    Okay: a = 1
    Okay: if a == 0:\n    a = 1
    E111:   a = 1
    E114:   # a = 1

    Okay: for item in items:\n    pass
    E112: for item in items:\npass
    E115: for item in items:\n# Hi\n    pass

    Okay: a = 1\nb = 2
    E113: a = 1\n    b = 2
    E116: a = 1\n    # b = 2
    r   r   zE11%d %szE11%d %s (comment)r   z!indentation is not a multiple of :r   zexpected an indented blockzunexpected indentationrt      r   )r   zover-indentedN)strendswith)rH   r   rn   r   r   indent_sizectmplindent_expectexpected_indent_amountexpected_indent_levels              r7   indentationr     sM     ,  qA%?::+?Dk! 
E/#k2B2BB
 
 
 	
 	
 	
 %--c22M :)>>>Q <======= :|.CCCQ 8999999 1&1T&9&9q 58N N///T00000000	1 1 0/r9   c           
   #   \  K   |d         d         d         }d|d         d         d         z   |z
  }	|s|	dk    rdS |                      d          }
dx}}|dk    r|fn||dz  f}dg|	z  }dg|	z  }dgg}dg}i }|d         d         }d}d}|d         g}|d	k    r0t          d
|d         d                                         z              |D ]\  }}}}}||d         |z
  k     }|r|d         |z
  }| o|t          v}|r|}|d	k    r$t          d|                                z              t	          |          |z
  ||<   |t
          j        k    o|dv }t          ||                   D ]}||         ||         z
  }||v } | r n||         r|||         k    } | o |dk    o|                    |d                   }|r!||         r|d         ||         k    r|dfV  n|r|s	|r|dfV  n||         r|d         ||         k     r|dur|dfV  ny| s|
r||         d|z  k    r|r|s|dfV  |||<   nV|du r|d         ||<   nF||t          fv rn:|dk    rd}!n(||         rd}!n|s||         rd}!n|||<   ||k    rd}!nd}!|d|!z  fV  ||         rZ|t
          j
        t
          j        fvr@||         s8|d         ||<   d||d         <   |dk    rt          d| d|d                     n|t
          j        t
          j        t          fv rt          ||d         <   nu|s|s|dv rd||d         dz   <   n^|s|s|s|dk    rd||d         dz   <   nC|dk    r=||d         d                                         r||                             |           |t
          j        k    r|dv r|dz  }|                    d           |                    d           t!          |          |k    r|                    g            ||                             |           ||xx         dz  cc<   |dk    r$t          d|d|d         d||                    n|d v r|dk    r|                                p|d         }"|                                 t%          |          D ]}#||#         |"k    rd||#<   t'          |          D ]}$|$|"k    r||$= ||dz   d= |dz  }|rd|||         <   t%          |dd          D ]}%||%         r||%xx         dz  cc<    nt!          |          |dz   k    sJ |d         |vr|||d         <   |d         |d         k    }|r||         ||d         |z
  <   |
r;t	          |          ||z   k    r'|d         |d         |z   f}&|rd!}'nd"}'|&d#|'z  fV  dS dS dS )$a2  Continuation lines indentation.

    Continuation lines should align wrapped elements either vertically
    using Python's implicit line joining inside parentheses, brackets
    and braces, or using a hanging indent.

    When using a hanging indent these considerations should be applied:
    - there should be no arguments on the first line, and
    - further indentation should be used to clearly distinguish itself
      as a continuation line.

    Okay: a = (\n)
    E123: a = (\n    )

    Okay: a = (\n    42)
    E121: a = (\n   42)
    E122: a = (\n42)
    E123: a = (\n    42\n    )
    E124: a = (24,\n     42\n)
    E125: if (\n    b):\n    pass
    E126: a = (\n        42)
    E127: a = (24,\n      42)
    E128: a = (24,\n    42)
    E129: if (a or\n    b):\n    pass
    E131: a = (\n    42\n 24)
    r   r   r   rF   Nr   rt   Fr   z>>> r   z... z]})z6E124 closing bracket does not match visual indentationz+E133 closing bracket is missing indentationTz7E128 continuation line under-indented for visual indentzIE123 closing bracket does not match indentation of opening bracket's line)E122z missing indentation or outdented)E127zover-indented for visual indent)E131zunaligned for hanging indent)E126z over-indented for hanging indent)E121z!under-indented for hanging indentz%s continuation line %szbracket depth z indent to )assertraiserB   r<   ([{z seen, col z, visual min = )]}zE129 visually indented linezE125 continuation linez(%s with same indent as next logical line)r   r   r|   NEWLINEr   r   OPreversedgetr   NLCOMMENTSTRINGFSTRING_STARTr   appendr}   poprangelist)(rH   r   r   hang_closingrn   r   r   verbose	first_rownrowsindent_nextrowdepthvalid_hangsparens
rel_indent	open_rowshangsindent_chanceslast_indentvisual_indentlast_token_multilinero   
token_typer   r   r   r   newlineclose_bracketopen_rowhanghanging_indenterrorr   dindidxposr   s(                                           r7   continued_indentationr     s     : q	!QIr
1a  9,E uzz '',,KOC%$/4$7$7;..;?+  S5[FuJIFEN)A,KM !nF!||fvay|**,,,---.4 F= F=*
D%da9,, 	M(Y&C..L:W3LG C	?K!||ft{{}},--- ,D11L@JsO (8;6H45=M %Yu%566  !#H)==!%!4! EU| 8"&%,"6!.. :4!8 :+//a99   +? +?8ve},,  #0 1 1 1 1 &?t &?   O!NNNNN !?58fUm#;#; ,,  #> ? ? ? ? ?K ?$.sOq;$F$F  D D  #C D D D D#e$&& %au4+--  199FEEE] 	LEEE& L5< LBEE#'E%Lk)) J K6>>>>> 3K 	)8;0@"AAA5M B!!HF5M'+N58$!||CuCCqCCDDDHOX-=}MMM'*N58$$ 	)U 	)t/J'J'J)-N3q6A:&& 	) 	)E 	)ddll)-N3q6A:&&S[[T#a&'']2244[e##C((( $$u}}
a   T"""y>>U**$$R(((% '',,,sq a<<E 55%(((F5MM; < < <5199$jjll<k!n		u & &Aay;..$%q	// 0 0Ck))*3/eaijj)
 948N6%=1 b"--  Cc{ sq( v;;%!)++++Qx~--+/uQx( %aCF 2 	=-7_Js1v	)* E}T**l[.HHHQx[01 	,0DD+D=DDDDDDDE EHHr9   c              #     K   |d         \  }}}}}t          dt          |                    D ]}||         \  }}}	}
}|t          j        k    r|dv r||	|k    rv|t          j        k    s|dv rb|dk     s||dz
           d         dk    rGt          j        |          s3t          j        dk     s|dk    st          j	        |          s	|d	|z  fV  |}|}|
}d
S )a  Avoid extraneous whitespace.

    Avoid extraneous whitespace in the following situations:
    - before the open parenthesis that starts the argument list of a
      function call.
    - before the open parenthesis that starts an indexing or slicing.

    Okay: spam(1)
    E211: spam (1)

    Okay: dict['key'] = list[index]
    E211: dict ['key'] = list[index]
    E211: dict['key'] = list [index]
    r   r   ([r   r   rC   r   	   r   zE211 whitespace before '%s'N)
r   r}   r   r   r   r   r   sysversion_infoissoftkeyword)rH   r   	prev_type	prev_text__prev_endru   r  r   r   r   s              r7   whitespace_before_parametersr    s       .4AY*Iy"hq#f++&&  +1%=(
D%b(+%%DLLX(-''9+=+=QYY&+A.'99!),, :  6))V##))44 $ 9D@@@@@		+ r9   c              #     K   t                               |           D ]}|                                \  }}d|v r|                    d          dfV  n,t	          |          dk    r|                    d          dfV  d|v r|                    d          dfV  t	          |          dk    r|                    d          dfV  dS )	zAvoid extraneous whitespace around an operator.

    Okay: a = 12 + 3
    E221: a = 4  + 5
    E222: a = 4 +  5
    E223: a = 4\t+ 5
    E224: a = 4 +\t5
    rt   r   zE223 tab before operatorz$E221 multiple spaces before operatorr   zE224 tab after operatorz#E222 multiple spaces after operatorN)OPERATOR_REGEXr   r   r   r}   r   s       r7   whitespace_around_operatorr    s        ((66 H H6>>++a.."<<<<<<[[1__++a.."HHHHH5==++a..";;;;;;ZZ!^^++a.."GGGGGH Hr9   c              #   *  K   d}t           j        }dx}}t           j        t           j        f}g }|D ]\  }}	}
}}|t           j        k    r|	dv r|                    |	           n|t          k    r|                    d           n|t           j        k    r|	dk    r|                    d           n|r|t           j        k    r|	dv r|                                 nV|t          k    r|                                 n6|d         dk    r*|t           j        k    r|	d	k    r|                                 |t          v r|t           j        k    rk|	d
v rg||d         |d         dz            }|t          vrE|dvrA|	d	k    r|dd         dgk    rn+|	d	k    r|dd         ddgk    rn|	dk    r|dv rn	|
d|	fV  |r|
|k    r|dur|d         s|d         dfV  d}n/|dk    r|	dv s|dk    r|	d	k    rn|du s|d         r|dfV  n7|dk    r1d\  }}|dk    rd\  }}n|t          vrd\  }}|d         |d|dfV  d}n||v r||	d k    r/|dd         dgk    s|dd         d!gk    s|dd         ddgk    rnt|	t          v rd}nh|	t          v rT|t           j        k    r|d"v s=|t           j        k    r/|t          vr&t          j        d#k     st          j        |          sd}n|	t"          v rd}|	||
|k    f}n|r|
|k    r|dfV  d}|}|	}|}dS )$aZ  Surround operators with the correct amount of whitespace.

    - Always surround these binary operators with a single space on
      either side: assignment (=), augmented assignment (+=, -= etc.),
      comparisons (==, <, >, !=, <=, >=, in, not in, is, is not),
      Booleans (and, or, not).

    - Each comma, semicolon or colon should be followed by whitespace.

    - If operators with different priorities are used, consider adding
      whitespace around the operators with the lowest priorities.

    Okay: i = i + 1
    Okay: submitted += 1
    Okay: x = x * 2 - 1
    Okay: hypot2 = x * x + y * y
    Okay: c = (a + b) * (a - b)
    Okay: foo(bar, key='word', *args, **kwargs)
    Okay: alpha[:-i]
    Okay: [a, b]
    Okay: (3,)
    Okay: a[3,] = 1
    Okay: a[1:4]
    Okay: a[:4]
    Okay: a[1:]
    Okay: a[1:4:2]

    E225: i=i+1
    E225: submitted +=1
    E225: x = x /2 - 1
    E225: z = x **y
    E225: z = 1and 1
    E226: c = (a+b) * (a-b)
    E226: hypot2 = x*x + y*y
    E227: c = a|b
    E228: msg = fmt%(errno, errmsg)
    E231: ['a','b']
    E231: foo(bar,baz)
    E231: [{'a':'b'}]
    FN>   {([flambdal>   }r   ]rF   r   >   r   r   ;r   r   r!  r  r   )]zE231 missing whitespace after Tr   z'E225 missing whitespace around operatorr   >   r   r   r   r   r   )E226
arithmeticr$   )E228modulo)E227zbitwise or shiftz missing whitespace around z	 operatorr(   r   r   r  )r   r   r   r   r   r   FSTRING_ENDSKIP_COMMENTS
WHITESPACEARITHMETIC_OPWS_NEEDED_OPERATORSUNARY_OPERATORSKEYWORDSr  r  r   r  WS_OPTIONAL_OPERATORS)rH   r   
need_spacer  r  r  operator_typesbrace_stackr  r   r   r   r   	next_charr   optypes                   r7   missing_whitespacer<  /  s     T JIIk8=1NK.4 o o*
D%d$$)@)@t$$$$=((s####8=((TX-=-=s#### 
	"X[((T_-D-D!!!!{**!!!!Os**(+--CKK!!!&&$$)@)@SVCFQJ./I
**y/F/F3;;;rss#3u#<#<S[[[%5#s%C%CS[[Y$%6%6!J$!J!JJJJJ G	#  T))*Q-)%a=DF F F F"

 $$)@)@ $$ %%A%"$MMMMMM$&&#7LD& C'''7ff"-77'Af%a=3744+A B B B B"

>))h.BCKK#BCC(SE11#BCC(SE11#BCC(S#J66 ,,,!

(( ++	U0B0B,,X--(611#1)<< 2 "&J...!
! '(9:

 # 1 1 IIIII"
		_o or9   c              #   (  K   | }t                               |          D ]r}|                                dz   }d|                                v r"|d|                                d         z  fV  Q|d|                                d         z  fV  sdS )zAvoid extraneous whitespace after a comma or a colon.

    Note: these checks are disabled by default

    Okay: a = (1, 2)
    E241: a = (1,  2)
    E242: a = (1,\t2)
    r   rt   zE242 tab after '%s'r   zE241 multiple spaces after '%s'N)WHITESPACE_AFTER_COMMA_REGEXr   r   rl   )rH   r   mr   s       r7   whitespace_around_commar@    s       D)22488 J J		A17799.1======:QWWYYq\IIIIIIJ Jr9   c              #     K   d}d}d}d}d}t          t                              |                     }d}d}	|D ]\  }
}}}}|
t          j        k    r|rd}||k    r||fV  |rd}||k    r||	fV  |
t          j        k    re|dv r|dz  }nW|dv r|dz  }nM|r|d	k    r	|dk    rd
}n<|dk    r	|dk    rd}n-|r+|dk    r%|r|dk    rd
}||k    r||	fV  nd
}||k    r||fV  |sd}|}dS )ac  Don't use spaces around the '=' sign in function arguments.

    Don't use spaces around the '=' sign when used to indicate a
    keyword argument or a default parameter value, except when
    using a type annotation.

    Okay: def complex(real, imag=0.0):
    Okay: return magic(r=real, i=imag)
    Okay: boolean(a == b)
    Okay: boolean(a != b)
    Okay: boolean(a <= b)
    Okay: boolean(a >= b)
    Okay: def foo(arg: int = 42):
    Okay: async def foo(arg: int = 42):

    E251: def complex(real, imag = 0.0):
    E251: return magic(r = real, i = imag)
    E252: def complex(real, image: float=0.0):
    r   FNz8E251 unexpected spaces around keyword / parameter equalsz/E252 missing whitespace around parameter equalsr  r   r)  r   Tr   r(   )boolr   rk   r   r   r   )rH   r   r   no_spacerequire_spacer  annotated_func_argin_defmessagemissing_messager  r   r   r   r   s                  r7   (whitespace_around_named_parameter_equalsrI    s     * FHMH&,,\::;;FHGGO.4    *
D%d$$ 	*H  )))) 	2!M  1111$$t||!! 2DCKKFaKK%)""1%*"" 2DCKK% 2&A++$(M(('9999#H(('1111 +%*"A   r9   c              #     K   d}|D ]\  }}}}}|t           j        k    r|d|d                                                  }|r-|d         |d         k    r|d         |d         dz   k     r|dfV  |                    d          \  }	}
}|	dvo|	                    d	          dd         pd	}|r|s|dd         t
          v r|d
fV  |r'|dk    s|d         dk    r|d	k    r|dfV  |r|dfV  |t           j        k    r|}dS )u  Separate inline comments by at least two spaces.

    An inline comment is a comment on the same line as a statement.
    Inline comments should be separated by at least two spaces from the
    statement. They should start with a # and a single space.

    Each line of a block comment starts with a # and one or multiple
    spaces as there can be indented text inside the comment.

    Okay: x = x + 1  # Increment x
    Okay: x = x + 1    # Increment x
    Okay: # Block comments:
    Okay: #  - Block comment list
    Okay: #  - Block comment list
    E261: x = x + 1 # Increment x
    E262: x = x + 1  #Increment x
    E262: x = x + 1  #  Increment x
    E262: x = x + 1  #  Increment x
    E265: #Block comment
    E266: ### Block comment
    )r   r   Nr   r   r   z.E261 at least two spaces before inline commentr3   z#:r   z*E262 inline comment should start with '# '!z)E265 block comment should start with '# 'z+E266 too many leading '#' for block comment)r   r   r   	partitionr   r1  r   )rH   r   r  r  r   r   r   r   inline_commentsymbolspcomment
bad_prefixs                r7   whitespace_before_commentrR  %  s     . H.4  *
D%d)))!)58)_2244N MA;%(**uQx(1+//I/I#KM M M M"&.."5"5FBt+Os1C1CBQB1G1N3J O N!
!:!:!MMMMM Os!2!2eAhll$$!LLLLLL O!NNNNN8;&&H% r9   c              #      K   | }|                     d          r/|                    d          }d|k     rd|d|         vr|dfV  dS dS dS dS )a   Place imports on separate lines.

    Okay: import os\nimport sys
    E401: import sys, os

    Okay: from subprocess import Popen, PIPE
    Okay: from myclas import MyClass
    Okay: from foo.bar.yourclass import YourClass
    Okay: import myclass
    Okay: import foo.bar.yourclass
    import r   rF   r'  Nz!E401 multiple imports on one line)r   find)rH   r   r   s      r7   imports_on_separate_linesrV  R  sx       Dy!! =		#::#T&5&\11<<<<<<<= =:11r9   c              #     K   d }d}|rdS | sdS |rdS |                      d          s                     d          r|                    dd          rdV  dS dS t          j        t                    rdS t          fd	|D                       rdS  |          r$|                    d
d          rd|d<   dS d|d
<   dS d|d<   dS )a  Place imports at the top of the file.

    Always put imports at the top of the file, just after any module
    comments and docstrings, and before module globals and constants.

    Okay: import os
    Okay: # this is a comment\nimport os
    Okay: '''this is a module docstring'''\nimport os
    Okay: r'''this is a module docstring'''\nimport os
    E402: a=1\nimport os
    E402: 'One string'\n"Two string"\nimport os
    E402: a=1\nfrom sys import x

    Okay: if x:\n    import os
    c                     | d         dv r
| dd          } | r| d         dv r
| dd          } | o| d         dk    p| d         dk    S )Nr   uUbBr   rR"r   rL   )r   s    r7   is_string_literalz8module_imports_on_top_of_file.<locals>.is_string_literalx  s_    7f8D 	DGtOO8D:aC947c>:r9   )r?   r@   r>   rA   rB   r<   r=   NrT  zfrom seen_non_importsF)r   z+E402 module level import not at top of filec              3   B   K   | ]}                     |          V  d S Nr   )r5   kwr   s     r7   r8   z0module_imports_on_top_of_file.<locals>.<genexpr>  s/      <<RT__R  <<<<<<r9   seen_docstringT)r   r   rerk   DUNDER_REGEXany)rH   r   checker_stater   r\  allowed_keywordsr   s         @r7   module_imports_on_top_of_filerh  f  sS     $; ; ;B    Dy!! 1T__W%=%= 1/77 	CBBBBBB	C 	C	,	%	% 1	<<<<+;<<<	<	< 1 			4	 	  1 -u55 	304M,---.2M*+++,0()))r9   c              #     K   | }t          |          dz
  }|                    d          }d}d dD             }d|cxk     r|k     rXn nTt          |||         |           |d         |d         k    r|d	         |d
         k    r|d         |d         k    r||dz            dk    rt                              |d|          }|ro|d|                                                                         }|dd         dk    r2|dd                                                                         rdV  njt          
                    |          rdV  n t          
                    |          r|dfV  |}|                    d|dz             }d|cxk     r|k     Rn |                    d          }d|k     r4||k     r|dfV  n|dfV  |                    d|dz             }d|k     2dS dS )a  Compound statements (on the same line) are generally
    discouraged.

    While sometimes it's okay to put an if/for/while with a small body
    on the same line, never do this for multi-clause statements.
    Also avoid folding such long lines!

    Always use a def statement instead of an assignment statement that
    binds a lambda expression directly to a name.

    Okay: if foo == 'blah':\n    do_blah_thing()
    Okay: do_one()
    Okay: do_two()
    Okay: do_three()

    E701: if foo == 'blah': do_blah_thing()
    E701: for x in lst: total += x
    E701: while t < 10: t = delay()
    E701: if foo == 'blah': do_blah_thing()
    E701: else: do_non_blah_thing()
    E701: try: something()
    E701: finally: cleanup()
    E701: if foo == 'blah': one(); two(); three()
    E702: do_one(); do_two(); do_three()
    E703: do_four();  # useless semicolon
    E704: def f(x): return 2*x
    E731: f = lambda x: 2*x
    r   r   r   c                     i | ]}|d S )r   rL   )r5   rq   s     r7   
<dictcomp>z'compound_statements.<locals>.<dictcomp>  s    +++$dA+++r9   z{}[]()rF   r  r%  r!  r&  r   r   r(   N)r   z1E731 do not assign a lambda expression, use a def)r   z*E704 multiple statements on one line (def)z,E701 multiple statements on one line (colon)r'  z0E702 multiple statements on one line (semicolon)z$E703 statement ends with a semicolon)r}   rU  update_countsLAMBDA_REGEXsearchr   r|   r   isidentifierr   rk   !STARTSWITH_INDENT_STATEMENT_REGEX)rH   r   	last_charr   
prev_foundcounts	lambda_kwr   s           r7   compound_statementsru    sa     < DD		AIIIcNNEJ++(+++F
u
 
 
 
 y
 
 
 
 
 d:e+,f555svc{**svc{**svc{**UQY3&&$++D!U;;I 0y000188::"##;#%%&"+*;*;*=*=*J*J*L*L%% % % %#))$// LEEEEE288>> LKKKKK
		#uqy))) u
 
 
 
 y
 
 
 
 * IIcNNE
u**9KKKKKK?????		#uqy)) u******r9   c              #     K   dx}x}}d}d}|D ]\  }}}	}
}|t           j        k    rd}|	d         |k    r|r
|r|s|dfV  |
d         |k    rh|                    d                              d          r3|
d         t	          |                                d                   d	z
  f}nd}|
d         x}}n|	d         }|t           j        k    r|d
v r|d	z  }|dv r|d	z  }dS )aB  Avoid explicit line join between brackets.

    The preferred way of wrapping long lines is by using Python's
    implied line continuation inside parentheses, brackets and braces.
    Long lines can be broken over multiple lines by wrapping expressions
    in parentheses.  These should be used in preference to using a
    backslash for line continuation.

    E502: aaa = [123, \\n       123]
    E502: aaa = ("bbb " \\n       "ccc")

    Okay: aaa = [123,\n       123]
    Okay: aaa = ("bbb "\n       "ccc")
    Okay: aaa = "bbb " \\n    "ccc"
    Okay: aaa = 123  # \\
    r   FNTz0E502 the backslash is redundant between bracketsr   \rF   r   r   r   )r   r   r|   r   r}   
splitlinesr   )rH   r   
prev_startr  r   rP  	backslashr  r   r   r   r   s               r7   explicit_line_joinr{    s7     $ &'&J&FGI.4  *
D%d)))G8z!!f!!7!OOOOOq6X{{6""++D11 ! VS):):2)>%?%?!%CD		 	$'F*JqJ$$u}}!!# r9   z()[]{},:.;@=%~)z...c                 <    | t           j        k    p|dv o|t          vS )N>   r,   r)   )r   r   _SYMBOLIC_OPS)r  r   s     r7   _is_binary_operatorr~    s-    hk! 	 	M!	r9   c              #      K   d}d}d}d}| D ]I\  }}}}}	|t           j        k    rd|v sd|v r|t           j        k    rd}4|||||||fV  |dv }d}|}|}JdS )zPrivate function to reduce duplication.

    This factors out the shared details between
    :func:`break_before_binary_operator` and
    :func:`break_after_binary_operator`.
    FTNrx   ry   z([{,;)r   r   r   )
r   
line_breakunary_contextprevious_token_typeprevious_textr  r   r   r   r   s
             r7   _break_around_binary_operatorsr    s       JMM.4 ! !*
D%d)))DLLDDLLjHO.K.KJJt%8-}e5 5 5 5 GOMJ", MM! !r9   c              #      K   t          |          D ]6}|\  }}}}}}}	t          ||          r|r|st          ||          s|	dfV  7dS )a  
    Avoid breaks before binary operators.

    The preferred place to break around a binary operator is after the
    operator, not before it.

    W503: (width == 0\n + height == 0)
    W503: (width == 0\n and height == 0)
    W503: var = (1\n       & ~2)
    W503: var = (1\n       / -2)
    W503: var = (1\n       + -1\n       + -2)

    Okay: foo(\n    -x)
    Okay: foo(x\n    [])
    Okay: x = '''\n''' + ''
    Okay: foo(x,\n    -y)
    Okay: foo(x,  # comment\n    -y)
    z&W503 line break before binary operatorNr  r~  )
rH   r   contextr  r   r  r  r  r  r   s
             r7   break_before_binary_operatorr  0  s      ( 2&99 B B-4	+T.	]E
D11 	Bj 	B!	B'(;(57 7	B AAAAAB Br9   c              #      K   d}t          |          D ]8}|\  }}}}}}	}
t          ||          r|r|	st          ||          s|dfV  |
}9dS )aF  
    Avoid breaks after binary operators.

    The preferred place to break around a binary operator is before the
    operator, not after it.

    W504: (width == 0 +\n height == 0)
    W504: (width == 0 and\n height == 0)
    W504: var = (1 &\n       ~2)

    Okay: foo(\n    -x)
    Okay: foo(x\n    [])
    Okay: x = '''\n''' + ''
    Okay: x = '' + '''\n'''
    Okay: foo(x,\n    -y)
    Okay: foo(x,  # comment\n    -y)

    The following should be W504 but unary_context is tricky with these
    Okay: var = (1 /\n       -2)
    Okay: var = (1 +\n       -1 +\n       -2)
    Nz%W504 line break after binary operatorr  )rH   r   ry  r  r  r   r  r  r  r  r   s              r7   break_after_binary_operatorr  N  s      . J1&99  -4	+T.	]E 3]CC 	F	F!	F (
D99	F EEEEE

 r9   c              #   x  K   |rdS t                               |           D ]}|                    d          p|                    d          }|                    d          dk    }d|rdnd|z   z  }|d	v rd
}nd}|dk    r|p|dk    o| }|d|rdndz  z  }|                    d          |d|d|fV  dS )aX  Comparison to singletons should use "is" or "is not".

    Comparisons to singletons like None should always be done
    with "is" or "is not", never the equality operators.

    Okay: if arg is not None:
    E711: if arg != None:
    E711: if None == arg:
    E712: if arg == True:
    E712: if False == arg:

    Also, beware of writing if x when you really mean if x is not None
    -- e.g. when testing whether a variable or argument that defaults to
    None was set to some other value.  The other value might have a type
    (such as a container) that could be false in a boolean context!
    Nr   r   r   r'   z'if cond is %s:'rZ   znot )r   E711E712r   r   z or 'if %scond:'z comparison to z should be )COMPARE_SINGLETON_REGEXr   rl   r   )rH   r   rk   	singletonsamemsgr   nonzeros           r7   comparison_to_singletonr  q  s     $  (11,?? 7 7KKNN4ekk!nn	A$& 4%;RRVy$HI	!!DDD!V+4 ;!W,9T %w)BFCCCkk!nn $iii 6 7 	7 	7 	7 	77 7r9   c              #      K   t                               |           }|r>|                    d          }|                    d          dk    r|dfV  dS |dfV  dS dS )aG  Negative comparison should be done using "not in" and "is not".

    Okay: if x not in y:\n    pass
    Okay: assert (X in Y or X is Z)
    Okay: if not (X in Y):\n    pass
    Okay: zz = x is not y
    E713: Z = not X in Y
    E713: if not X.B in Y:\n    pass
    E714: if not X is Y:\n    pass
    E714: Z = not X.B is Y
    r   r   r*   z+E713 test for membership should be 'not in'z0E714 test for object identity should be 'is not'N)COMPARE_NEGATIVE_REGEXrn  r   rl   )rH   rk   r  s      r7   comparison_negativer    s       #)),77E Jkk!nn;;q>>T!!DDDDDDDIIIIIIIJ Jr9   c              #      K   t                               |           }|rR|sR|                    d          }|r|                                r|t          vrdS |                                dfV  dS dS dS )zObject type comparisons should `is` / `is not` / `isinstance()`.

    Do not compare types directly.

    Okay: if isinstance(obj, int):
    Okay: if type(obj) is int:
    E721: if type(obj) == type(1):
    r   NzgE721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`)COMPARE_TYPE_REGEXrn  rl   ro  r   r   )rH   r   rk   insts       r7   comparison_typer    s       %%l33E 
T 
{{1~~ 	D%%'' 	D
,B,BFKKMM5
 	
 	
 	
 	
 	
	
 
 
 
r9   c              #   ~   K   |rdS t                               |           }|r|                                dfV  dS dS )zWhen catching exceptions, mention specific exceptions when
    possible.

    Okay: except Exception:
    Okay: except BaseException:
    E722: except:
    NzE722 do not use bare 'except')BLANK_EXCEPT_REGEXrk   r   )rH   r   rk   s      r7   bare_exceptr    sZ        $$\22E =kkmm<<<<<<<= =r9   c              #     K   d}d}d}d}|d         \  }}}}	}
t          dt          |                    D ]}||         \  }}}}}dx}}|dv r|}d}n||dk    r||k    rd}|d	v r|dz  }n	|d
v r|dz  }|dk    s|dk    r|dk    r||v r|}|}|dv r||v r|}|}|7|s5|t          |          dz
  k     r||dz            d         dv r|dv r||v r|}|}|dk    r||v r	|d|z  fV  |dk    r||v r	|d|z  fV  |r	|d|z  fV  |}|}dS )a  Never use the characters 'l', 'O', or 'I' as variable names.

    In some fonts, these characters are indistinguishable from the
    numerals one and zero. When tempted to use 'l', use 'L' instead.

    Okay: L = 0
    Okay: o = 123
    Okay: i = 42
    E741: l = 0
    E741: O = 123
    E741: I = 42

    Variables can be bound in several other contexts, including class
    and function definitions, lambda functions, 'global' and 'nonlocal'
    statements, exception handlers, and 'with' and 'for' statements.
    In addition, we have a special handling for function parameters.

    Okay: except AttributeError as o:
    Okay: with lock as L:
    Okay: foo(l=12)
    Okay: foo(l=I)
    Okay: for a in foo(l=12):
    Okay: lambda arg: arg * l
    Okay: lambda a=l[I:5]: None
    Okay: lambda x=a.I: None
    Okay: if l >= 12:
    E741: except AttributeError as O:
    E741: with lock as l:
    E741: global I
    E741: nonlocal l
    E741: def foo(l):
    E741: def foo(l=12):
    E741: l = foo(l=12)
    E741: for l in range(10):
    E741: [l for l in lines if l]
    E741: lambda l: None
    E741: lambda a=x[1:5], l: None
    E741: lambda **l:
    E741: def f(**l):
    E742: class I(object):
    E743: def l(x):
    NFr   )r$  OIr   >   r:   r#  r   Tr   r   r-   r(   )asr;   globalnonlocalz:,=)>   r   r#  r   r   r   rC   z$E742 ambiguous class definition '%s'r:   z'E743 ambiguous function definition '%s'z!E741 ambiguous variable name '%s')r   r}   )rH   r   
func_depth
seen_colonbrace_depthidents_to_avoidr  r  ry  r  r  ru   r  r   r   r   r   identr  s                      r7   ambiguous_identifierr    s     X JJK%O5;AY2Iy*hq#f++&& 0 0-3E]*
D%d)))$JJJ&z))J5==1KKU]]1K4<<DCKKK1,<,<O++!  ;;;&& & 'Fa''F519,=a,@F,J,J<<<''EC&&CdJJJJJ&&FMMMMM 	C:UBBBBB	

a0 0r9   c           	   #     K   |rdS g d}g }|D ]T\  }}}}}|t           j        t          hv rH|                    |d|                    |d                                                                       |t           j        t          hv rd|d         vr|\  }	}
|                    d          }|dk    r|dz  }||         |vrX|	|                    dd|          z   }||	k    r|
|z   }n||	                    dd|          z
  dz
  }||dz
  fd	||          d
fV  |                    d|dz             }|dk    |t           j        t          hv r|                                 VdS )zsInvalid escape sequences are deprecated in Python 3.6.

    Okay: regex = r'\.png$'
    W605: regex = '\.png$'
    N)rx   rw  r   r[  abr"  nrtv01234567xNuUrF   r  rw  r   r   rx   zW605 invalid escape sequence '\r   )r   r   r   r   ru   lowerFSTRING_MIDDLErU  countrfindr/  r   )rH   r   r   validprefixesr  r   r   _
start_line	start_colr  r   cols                 r7   #python_3000_invalid_escape_sequencer  7  s         E* H)/  %
D%A(/=999OOD!6$**T"X"6"6!67==??@@@(/>:::(2,&&(-%
IiiooQhh1HCCy--)DJJtQ,D,DD:--"+c/CC"%

4C(@(@"@1"DC!37OKtCyKKK    ))D#'22C Qhh (/;777LLNNN1 r9   c              #     K   ||rdS d}t                      }|D ]D\  }}}}	}
|t                              t          j        g          vr|                    |
           E|D ]|\  }}}}	}
|t          j        k    r|r|t          j        t          j        fv rC|
|t          v r7|
                                }t          |          D ]\  }}|d         |z   dk    r|

                    d          r  dS t          |          }|                                }|t          j        k    r5t          |          dk    r"|t          |d                   z
  t          k     rt          |          dk    rK|dz   t          |          k     r5t          |          dk    r"|t          |d                   z
  t          k     r||k    r|d         |z   |f}|d||fz  fV  |}~dS )zLimit all doc lines to a maximum of 72 characters.

    For flowing long blocks of text (docstrings or comments), limiting
    the length to 72 characters is recommended.

    Reports warning W505
    Nr   r   r   r   rF   z+W505 doc line too long (%d > %d characters))setr0  unionr   r   addr   SKIP_TOKENSrx  rm   r   r}   r   MAX_DOC_LENGTH)rH   max_doc_lengthr   r   
prev_token
skip_linesr  r   r   r   r   r   line_numrG   r   r   	doc_errors                    r7   maximum_doc_lengthr  t  s'      JJ.4 ! !*
D%d]00(/1BCCCCNN4   .4    *
D%d((Z((/8+;<<<!Z;%>%>))/8/?/? ; ;+HmQx(*a//DOOD4I4I/ //F*0022F!X%555KK1,, &VBZ 8> I I$6{{a''HqL3u::,E,EKK1,, &VBZ 8> I I$..%*1X%8.$I	( +A"(.!9+: ; ; ; ;  

5   r9   c                 B   	 t          j        |           5 }|                                cddd           S # 1 swxY w Y   dS # t          t          t
          f$ rC t          | d          5 }|                                cddd           cY S # 1 swxY w Y   Y dS w xY w)zRead the source code.Nzlatin-1)encoding)r   open	readlinesLookupErrorSyntaxErrorUnicodeError)filenamer"  s     r7   r  r    s3   !]8$$ 	!;;==	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!l3 ! ! !(Y/// 	!1;;==	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!!sP   A 7A ;A ;A (B,B BB	BB	BBc                  p    t          j        t          j        j        d                                          S )zRead the value from stdin.ignore)errors)ioTextIOWrapperr  stdinbufferreadrL   r9   r7   stdin_get_valuer    s)    CI,X>>>CCEEEr9   i   z# no(?:qa|pep8)\bc                     |                      d          } d| vr1t          |           t          |                                           z
  S d}| D ] }|dk    r|dz  dz  dz   }|dk    r|dz  }  |S )zXReturn the amount of indentation.

    Tabs are expanded to the next multiple of 8.
    z
rt   r   r   r3   r   )r|   r}   r   )r   resultrq   s      r7   r   r     s    
 ;;vD44yy3t{{}}----F  4<<q[1_q(FFS[[aKFFMr9   c                     |                      | d                   dz   }t          |           dz
  }| dd         dv r
|dz  }|dz  }| d|         d||z
  z  z   | |d         z   S )z7Replace contents with 'xxx' to prevent syntax matching.rF   r   N)z"""z'''r   r  )ru   r}   )r   r   r   s      r7   mute_stringr    s{     JJtBx  1$E
d))a-CBCCyN""
q<#u--STT
::r9   .c                 L   i }dx}}|                                  D ]}|r|dd         dk    r|dz  }|dd         dk    rht                              |          }d |                                D             \  }}||                             t          |||z                        |dd         dk    rK|dd                             d	d          d
         }|dd         dv r
|dd         }t                      ||<   fd|                                D             S )z&Return a dictionary of matching lines.Nr   r   r   z@@ c              3   8   K   | ]}t          |pd           V  dS )r  N)int)r5   gs     r7   r8   zparse_udiff.<locals>.<genexpr>  s,      GGaCSMMGGGGGGr9   z+++r   rt   r   r   )zb/zw/zi/c                 |    i | ]8\  }}|t          |          t          j                            |          |9S rL   )filename_matchospathjoin)r5   filepathrowsparentpatternss      r7   rk  zparse_udiff.<locals>.<dictcomp>  sY       Xt #8X66
VX&&  r9   )	rx  
HUNK_REGEXrk   r   updater   r   r  items)	diffr  r  rvr  r   r   
hunk_matchr   s	    ``      r7   parse_udiffr    s_    
BD5!!   	BQBx3
8u#))$//JGG:3D3D3F3FGGGLS%tHOOE#sU{334444"1"X8>>$**1-D BQBx---ABBxuuBtH     "

   r9   c                 j   | sg S t          | t                    r| S g }|                     d          D ]}|                                }d|v r=t          j                            t          j                            ||                    }|                    |	                    d                     |S )zQParse a comma-separated list of paths.

    Return a list of absolute paths.
    r   r   )

isinstancer   r   r   r  r  abspathr  r   r|   )valuer  pathsr  s       r7   normalize_pathsr    s    
  	% EC   ' 'zz||$;;7??27<<#=#=>>DT[[%%&&&&Lr9   Tc                 B     |s|S t           fd|D                       S )z{Check if patterns contains a pattern that matches filename.

    If patterns is unspecified, this always returns True.
    c              3   8   K   | ]}t          |          V  d S r_  r   )r5   patternr  s     r7   r8   z!filename_match.<locals>.<genexpr>  s-      BBgwx))BBBBBBr9   )re  )r  r  r   s   `  r7   r  r  
  s5    
  BBBBBBBBBBr9   c                 8    | D ]}||v r||xx         dz  cc<   dS )z^Adds one to the counts of each appearance of characters in s,
        for characters in countsr   NrL   )r6   rs  rq   s      r7   rl  rl    s=       6>>4LLLALLL r9   c                     | d         t           v p1| d         | d         d         d                                          dk    S )Nr   r   r   r   z\
)r   r   )tokens    r7   _is_eol_tokenr    s<    8wK%(58A;<<"8"?"?"A"AV"KKr9   c                   b    e Zd ZdZ	 	 ddZd Zd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd ZddZdS )Checkerz;Load a Python source file, tokenize it, check coding style.Nc                    |t          |          j        }n|rJ d | _        |j        | _        |j        | _        |j        | _        |j	        | _	        |j
        | _
        |j        | _        d| _        d| _        |j        | _        |j        | _        |j        | _        || _        i | _        |d| _        |pg | _        n|dk    r.d| _        t'                                          d          | _        ne|\	 t+          |          | _        nM# t,          $ r9 t/          j                    d d         \  }}|j         d| | _        g | _        Y nw xY w|| _        | j        r~t5          | j        d         d                   }|dv rZ|d	k    r| j        d         d
d          | j        d<   n6| j        d         d d         dk    r| j        d         dd          | j        d<   |p|j        | _        | j        j        | _        d| _        d S )Nr   Fr  r   Tr   : )     r  r   r   u   ï»¿)
StyleGuideoptions	_io_errorphysical_checks_physical_checkslogical_checks_logical_checks
ast_checks_ast_checksr   r  r   fstring_startr   r   r   r  _checker_statesr   r  rx  r  OSErrorr  exc_info__name__ordreportr	  report_errorr   )	ra   r  r   r  r!  kwargsexc_typeexcord0s	            r7   rg   zChecker.__init__(  s   ? ((0GG: ' 7&5"-&6%4".#0". !#DM"DJJ__#DM(**55d;;DJJ] &x00

      "%,..!"43$,$5!>!>!>!>


 
 DJ: 	6tz!}Q'((D~%%6>>$(JqM!""$5DJqMMZ]2A2&.88$(JqM!""$5DJqM. K-			s   5D
 
A EEc           	      N   t          j                    dd         \  }}t          |j                  dk    r+|j        d         }t          |          dk    r
|dd         }nd}|                     |d         |d         pdd|j         d|j        d          | j                   dS )	zCheck if the syntax is valid.Nr   r   r   )r   r   r   zE901 r  )r  r  r}   r_   r"  r  report_invalid_syntax)ra   r$  r%  rp   s       r7   r(  zChecker.report_invalid_syntaxW  s    ,..!,3sx==1Xa[F6{{Q!F&)VAY^!D("3DDsx{DD4	6 	6 	6 	6 	6r9   c                     | j         | j        k    rdS | j        | j                  }| xj         dz  c_         | j        |dd         t          v r|d         | _        |S )z(Get the next line from the input buffer.rZ   r   Nr   )r   r   r   rn   r1  )ra   r   s     r7   readlinezChecker.readlined  sg    t///2z$*+A#RaRJ(>(>#AwDr9   c                 `    g }|D ]%}|                     t          | |                     & || S )zRun a check plugin.)r   getattr)ra   r]   argument_names	argumentsrO   s        r7   	run_checkzChecker.run_checkn  sD    	" 	2 	2DWT4001111ui  r9   c                 R    d|v r"| j                             |i           | _        dS dS )z5Prepare custom state for the specific checker plugin.rf  N)r  
setdefaultrf  )ra   rO   r-  s      r7   init_checker_statezChecker.init_checker_stateu  s6    n,,!%!5!@!@r!J!JD -,r9   c                    || _         | j        D ]q\  }}}|                     ||           |                     ||          }|=|\  }}|                     | j        |||           |dd         dk    r|d         | _        rdS )z,Run all physical checks on a raw input line.Nr   E101r   )rG   r  r2  r/  r"  r   rn   )ra   r   rO   r]   r-  r  rp   r   s           r7   check_physicalzChecker.check_physicalz  s    !+/+@ 	/ 	/'D%##D.999^^E>::F!!'!!$"2FD%HHH8v%%'+AwD$	/ 	/r9   c                    g }g }d}dx}x}}| j         D ]\  }}}	}
}|t          v r|sd|	fg}|t          j        k    r|                    |           @|t          j        k    rt          |          }n|t          k    rdt          |          z  }|rK|	\  }}||k    r-| j	        |dz
           |dz
           }|dk    s|dvr	|dvrd|z   }n||k    r|||         |z   }|                    |           |t          |          z  }|                    ||
f           |
\  }}d	
                    |          | _        |o!t          d	
                    |                    | _        |S )
z!Build a logical line from tokens.r   Nr  r   r   z{[(r   r3   rZ   )r   r  r   r   r   r   r  r  r}   r   r  rH   r   )ra   logicalcommentsr   prev_rowprev_colmappingr  r   r   r   r   	start_rowr  r  s                  r7   build_tokens_linezChecker.build_tokens_line  s   (,,,8g26+ 	' 	'.JeS$[(( 'u:,X---%%%X_,,"4((~--SYY ;).&Iy(( $
8a< 8A FI C''IU,B,B,0,=,="Tz** 23d:DNN4   c$iiFNNFC=)))#& XxxGGG,,8bggh&7&7!8!8	r9   c                    | j                                          |                                 }|sdS d |D             }|d         d         \  }}| j        |dz
           }t	          |d|                   | _        | j        | j        k     r| j        | _        | j        dk    r.t          | j
        dd                                                    | j        D ]\  }}}| j        dk    rt          d|z              |                     ||           |                     ||          pd	D ]r\  }	}
t          |	t                     s4|t#          j        ||	                   \  }}|d         |d         |	z   |z
  f}	|                     |	d         |	d         |
|           s| j
        r+| j        | _        | j
        | _        | j        s| j
        | _        d| _        g | _        dS )
z:Build a line from tokens and run all logical checks on it.Nc                     g | ]\  }}|S rL   rL   )r5   rp   r  s      r7   rQ   z)Checker.check_logical.<locals>.<listcomp>  s    ;;;ifa6;;;r9   r   r   r   P   r   z   rL   )r!  increment_logical_liner=  r   r   r   r   r   r   r   rH   r|   r  r2  r/  r   tuplebisectbisect_leftr"  r   r   r   r   )ra   r;  mapping_offsetsr<  r  r  rO   r]   r-  rp   r   token_offsetr  s                r7   check_logicalzChecker.check_logical  s   **,,,((** 	F;;7;;;!(AIZ	A.
)*ZiZ*@AAt/// $ 0D<1$#CRC(//11222+/+? 	E 	E'D%|q  edl#####D.999 $un E E K E E!&%00 F )00B'11 11 )2%L#!!fc!fvo&DEF!!&)VAYeDDDDE  	J)-):D&$($5D!$ J8<8I5r9   c                    	 t          d                    | j                  ddt                    }n1# t          t
          t          f$ r |                                 cY S w xY w| j        D ]o\  }}} ||| j	                  }|
                                D ]C\  }}}}	| j        rt          | j        |dz
                     s|                     ||||	           DpdS )z,Build the file's AST and run all AST checks.rZ   execr   N)compiler  r   PyCF_ONLY_AST
ValueErrorr  	TypeErrorr(  r  r  runr   r"  )
ra   rI   rO   clsr  checkerlinenorp   r   r]   s
             r7   	check_astzChecker.check_ast  s   	02774:..FMJJDDK3 	0 	0 	0--/////	0!- 	C 	CMD#rc$..G/6{{}} C C+ez Cdj!.D)E)E C%%ffdEBBBC	C 	Cs   /2 +A A c              #     K   | j         r%|                     ddd| j         z  t                     t          j        | j                  }	 d}|D ]`}|d         d         | j        k    r dS |d         ot          |d                   | _        |                     ||           |V  |d         }adS # t          t          j
        f$ r |                                  Y dS w xY w)z9Tokenize file, run physical line checks and yield tokens.r   r   zE902 %srZ   r   Nr   )r  r"  r  r   generate_tokensr*  r   r   maybe_check_physicalr  
TokenErrorr(  )ra   tokengenprev_physicalr
  s       r7   rT  zChecker.generate_tokens  s     > 	KaI$>	JJJ+DM::
	)M! ) )8A;!111FF!!H7eAh	))%??? %a) ) X01 	) 	) 	)&&((((((	)s   	B0 )AB0 0*CCc                    |j         t          k    r|j        d         | _        dS t	          |          r>|j        dk    r|                     |           dS |                     |j                   dS |j         t          j        k    r	d|j	        v s|j         t          k    rt          |j                  rdS |j         t          k    r| j        }n|j        d         }|j        d         }d| _        || _        t          ||          D ]8}|                     | j        |dz
           dz              | xj        dz  c_        9d| _        dS dS )z9If appropriate for token, check current physical line(s).r   rZ   rx   NTr   F)r   r   r   r  r  r   r5  r   r   r   r/  r   r   r   r   r   r   )ra   r
  rX  r   r   r   s         r7   rU  zChecker.maybe_check_physical  s^    :&&!&QD5!! (	# zR##M22222##EJ/////
ho--$%,2F2F
k))" EJ z[((*A)A,C!DN$D$UC00 & &##DJ{Q$?$$FGGG  A%   "DNNN= *)r9   r   c                    | j                             | j        | j        ||           t	          | j                  | _        | j        r|                                  d| _        d| _	        dx| _
        | _        d| _        d| _        g | _        dx| _        | _        d}|                                 D ]t}| j                            |           |dd         \  }}| j        dk    r|d         d         |d         d         k    r1d                    |d         d         pd|d         d                   }nd|d         d         z  }t+          d	|d         d         d
|d
t,          j        |d                  d
|           |t,          j        k    r|dv r|dz  }|dv r|dz  }|s||t2          v rs|t,          j        k    r|                                  d| _        .t	          | j                  dk    r| xj        dz  c_        | j        d= `|                                  v| j        r4|                     | j        d                    |                                  | j                                         S )z!Run all checks on the input file.r   NrZ   r   r   z[{}:{}]r   zl.%szl.rt   r   r   rF   )r!  	init_filer  r   r}   r   r  rR  r   rn   r   r   r   r   r   r   r   rT  r   r   r   r   r   tok_namer   r   rG  r5  get_file_results)ra   expectedline_offsetr   r
  r  r   r  s           r7   	check_allzChecker.check_all  s   dmTZ;OOOtz?? 	NN9::D6 "02-/004,))++ 	- 	-EKu%%%$QqSzJ|q  8A;%(1+--#**58A;+<"eAhqkJJCC 58A;.CQx{{{CCC):58)D)D)DddL M M MX[((5==aKFFU]]aKF 
-((!X%555**,,,,-))T[))Q..((A-(( KNN**,,,; 	!
2///   {++---r9   )NNNNNr   )r  
__module____qualname__re   rg   r(  r*  r/  r2  r5  r=  rG  rR  rT  rU  r`  rL   r9   r7   r  r  %  s        EE,0&*- - - -^6 6 6  ! ! !K K K

/ 
/ 
/! ! !F! ! !F
C 
C 
C) ) )"/# /# /#b+. +. +. +. +. +.r9   r  c                   ^    e Zd ZdZdZd Zd Zd Zd Zd Z	d Z
d	 ZddZddZddZd ZdS )
BaseReportz"Collect the results of the checks.Fc                     |j         | _        |j        | _        d| _        d| _        t                              | j        d          | _        i | _	        d S ra  )
benchmark_keys_benchmark_keysignore_code_ignore_codeelapsedtotal_errorsdictfromkeyscountersmessages)ra   r  s     r7   rg   zBaseReport.__init__M  sJ    &5#/d&:A>>r9   c                 6    t          j                     | _        dS )zStart the timer.N)time_start_timera   s    r7   r   zBaseReport.startV  s    9;;r9   c                 F    t          j                     | j        z
  | _        dS )zStop the timer.N)rr  rs  rk  rt  s    r7   stopzBaseReport.stopZ  s    y{{T%55r9   c                     || _         || _        |pd| _        || _        d| _        | j        dxx         dz  cc<   | j        dxx         t          |          z  cc<   dS )Signal a new file.rL   r   r/   r   r1   N)r  r   r^  r_  file_errorsro  r}   )ra   r  r   r^  r_  s        r7   r[  zBaseReport.init_file^  st     
 B&g!#&'''3u::5'''''r9   c                 0    | j         dxx         dz  cc<   dS )zSignal a new logical line.r0   r   N)ro  rt  s    r7   rA  z!BaseReport.increment_logical_lineh  s&    o&&&!+&&&&&r9   c                 X   |dd         }|                      |          rdS || j        v r| j        |xx         dz  cc<   nd| j        |<   |dd         | j        |<   || j        v rdS | j        r| j        st          | j                   | xj        dz  c_        | xj        dz  c_        |S )&Report an error, according to options.Nr   r      )	rj  ro  rp  r^  print_filenamery  r   r  rl  )ra   r   rp   r   r]   r   s         r7   r	  zBaseReport.errorl  s    BQBxT"" 	F4=  M$1$"#DM$"&qrr(DM$4=  F 	!t'7 	!$-   AQr9   c                     | j         S )z6Return the count of errors and warnings for this file.)ry  rt  s    r7   r]  zBaseReport.get_file_results  s    r9   rZ   c                 H     t           fd j        D                       S )z.Return the total count of errors and warnings.c              3   \   K   | ]&}|                               j        |         V  'd S r_  )r   ro  r5   keyprefixra   s     r7   r8   z'BaseReport.get_count.<locals>.<genexpr>  sW       G Gs~~f/E/EG4=% G G G G G Gr9   )sumrp  ra   r  s   ``r7   	get_countzBaseReport.get_count  sN     G G G G G"mG G G G G 	Gr9   c                 H      fdt           j                  D             S )a
  Get statistics for message codes that start with the prefix.

        prefix='' matches all errors and warnings
        prefix='E' matches all errors
        prefix='W' matches all warnings
        prefix='E4' matches all errors that have to do with imports
        c                 |    g | ]8}|                               j        |         d d|dj        |         9S )r  r3   )r   ro  rp  r  s     r7   rQ   z-BaseReport.get_statistics.<locals>.<listcomp>  se     L L LCNN64J4JLc 2 2 2 2CCCs9K9KL L L Lr9   )sortedrp  r  s   ``r7   get_statisticszBaseReport.get_statistics  sG    L L L L L!$-00L L L 	Lr9   c                 T    |                      |          D ]}t          |           dS )z9Print overall statistics (number of errors and warnings).N)r  r   )ra   r  r   s      r7   print_statisticszBaseReport.print_statistics  s6    ''// 	 	D$KKKK	 	r9   c                     t          d                    | j        d                     | j        r=| j        D ]7}t          d| j        |         | j        z  || j        |         fz             6dS dS )zPrint benchmark numbers.z{:<7.2f} {}zseconds elapsedz%-7d %s per second (%d total)N)r   r   rk  rh  ro  )ra   r  s     r7   print_benchmarkzBaseReport.print_benchmark  s    m""4<1BCCDDD< 	,+ , ,5}S)DL8#}S)++ , , , ,	, 	,, ,r9   NrZ   )r  rb  rc  re   r~  rg   r   rv  r[  rA  r	  r]  r  r  r  r  rL   r9   r7   re  re  H  s        ,,N  ' ' '6 6 66 6 6, , ,  &     G G G G
	L 	L 	L 	L   
, , , , ,r9   re  c                       e Zd ZdZdZdS )
FileReportz:Collect the results of the checks and print the filenames.TN)r  rb  rc  re   r~  rL   r9   r7   r  r    s        DDNNNr9   r  c                   <     e Zd ZdZ fdZ fdZ fdZd Z xZS )StandardReportz,Collect and print the results of the checks.c                 
   t                                          |           t                              |j                                        |j                  | _        |j        | _        |j	        | _
        |j        | _        d S r_  )superrg   REPORT_FORMATr   r   r  _fmtrepeat_repeatshow_source_show_source	show_pep8
_show_pep8ra   r  	__class__s     r7   rg   zStandardReport.__init__  si    !!!!%%gn&:&:&<&<&-n6 6	~#/!+r9   c                 Z    g | _         t                                          ||||          S )rx  )_deferred_printr  r[  )ra   r  r   r^  r_  r  s        r7   r[  zStandardReport.init_file  s0    !ww  eX{4 4 	4r9   c                     t                                          ||||          }|rD| j        |         dk    s| j        r,| j                            ||||dd         |j        f           |S )r|  r   r}  N)r  r	  ro  r  r  r   re   )ra   r   rp   r   r]   r   r  s         r7   r	  zStandardReport.error  sz    ww}}[&$>> 	FT]4(A--- ''fdDHemDF F Fr9   c           
      X   | j                                          | j         D ]\  }}}}}t          | j        | j        | j        |z   |dz   ||dz             | j        rz|t          | j                  k    rd}n| j        |dz
           }t          |	                                           t          t          j        dd|d|                   dz              | j        r&|r$t          d|                                z              t          j                                         | j        S )	z9Print results and return the overall count for this file.r   )r  r   r  r   r   rZ   z\Sr3   Nr!   z    )r  sortr   r  r  r_  r  r}   r   r|   rc  subr  r   r  stdoutflushry  )ra   r   rp   r   r   docr   s          r7   r]  zStandardReport.get_file_results  s8   !!###484H 	 	0KtS$)'+5fqjd     
   ?TZ00DD:kAo6Ddkkmm$$$bfUCgvg77#=>>> ,3 ,fsyy{{*+++ Jr9   )	r  rb  rc  re   rg   r[  r	  r]  __classcell__r  s   @r7   r  r    s        66, , , , ,4 4 4 4 4                 r9   r  c                   ,     e Zd ZdZ fdZ fdZ xZS )
DiffReportz9Collect and print the results for the changed lines only.c                 b    t                                          |           |j        | _        d S r_  )r  rg   selected_lines	_selectedr  s     r7   rg   zDiffReport.__init__  s)    !!! /r9   c                 x    || j         | j                 vrd S t                                          ||||          S r_  )r  r  r  r	  )ra   r   rp   r   r]   r  s        r7   r	  zDiffReport.error  s8    dnT];;;Fww}}[&$>>>r9   )r  rb  rc  re   rg   r	  r  r  s   @r7   r  r    sW        CC0 0 0 0 0? ? ? ? ? ? ? ? ?r9   r  c                   J    e Zd ZdZd ZddZddZddZd Zdd	Z	d
 Z
d ZdS )r  z-Initialize a PEP-8 instance with few options.c                 <   |                     dt                    | _        |                     dd          }|                     dd          }|                     dd           }t          |i |}|rd n|                    dd           }|                    dd           }t          |||||          \  }	| _        |r+|	j                            |           d|v r|d         | _        | j	        | _
        |	| _        |	j        s|	j        rt          nt          |	_        t!          |	j        pd          |	_        |	j        s;|	j        s4t&          r-t!          t&                              d	                    |	_        n"|	j        rd
nt!          |	j                  |	_        t*          d d          |	_        | j        |	_        |                     d          |	_        |                     d          |	_        |                     d          |	_        |                                  d S )Nchecker_class
parse_argvFconfig_fileparserr  r   rL   r   r  rG   rH   rI   )r   r  r  rm  r   process_optionsr  __dict__r  
input_filerunnerr  reporterquietre  r  rB  selectr  DEFAULT_IGNOREr   BENCHMARK_KEYSrg  ri  
get_checksr  r  r  init_report)
ra   r_   r#  r  r  r  options_dictarglistr   r  s
             r7   rg   zStyleGuide.__init__  s   #ZZAAZZe44
jj66Hd++T,V,,$I$$,*:*:7D*I*I""9d33-Zfg? ? 	3##L111,&&)'2
o 	O-4]NzzGw~344 	P'. 	Pn 	P">#7#7#<#<==GNN '.nOUU%:O:OGN!/!2"."&///"B"B!%!@!@!__V44r9   Nc                 f     |p| j         j        | j                   | j         _        | j         j        S )zInitialize the report instance.)r  r  r!  )ra   r  s     r7   r  zStyleGuide.init_report	  s-    @x@4<+@$,OO|""r9   c                    || j         }| j        j        }| j        }|                                 	 |D ]W}t
          j                            |          r|                     |           7| 	                    |          s ||           Xn# t          $ r t          d           Y nw xY w|                                 |S )zRun all checks on the paths.Nz... stopped)r  r  r!  r  r   r  r  isdir	input_direxcludedKeyboardInterruptr   rv  )ra   r  r!  r  r  s        r7   check_fileszStyleGuide.check_files	  s    =JE$	! ! !7==&& !NN4((((t,, !F4LLL	!
 ! 	! 	! 	!-     	!s   AB B)(B)r   c                     | j         j        rt          d|z             |                     ||| j                   }|                    ||          S )z'Run all checks on a Python source file.zchecking %s)r   r  )r^  r_  )r  r   r   r  r`  )ra   r  r   r^  r_  fcheckers         r7   r  zStyleGuide.input_file*	  s^    < 	,-(*+++%%E4< & 9 9!!8!MMMr9   c                 x   |                     d          }|                     |          rdS | j        j        j        }| j        j        }| j        j        }| j        }t          j	        |          D ]\  }}}|rt          d|z              |dxx         dz  cc<   t          |          D ]-}	|                     |	|          r|                    |	           .t          |          D ]Q}
t          |
|          r?|                     |
|          s) |t          j                            ||
                     RdS )z9Check all files in this directory and all subdirectories.r   r   z
directory r.   r   N)r|   r  r  r!  ro  r   r  r  r  walkr   r  remover  r  r  )ra   dirnamero  r   filepatternsr  rootdirsr/   subdirr  s              r7   r  zStyleGuide.input_dir2	  sZ   ..%%==!! 	1<&/,&|,!#!1!1 	9 	9D$ +lT)***]###q(### ,, ( (==.. (KK'''"5MM 9 9 #8\::9h559 F27<<h778889	9 	9r9   c                 J   | j         j        sdS t          j                            |          }t          || j         j                  rdS |r t          j                            ||          }t          j                            |          }t          || j         j                  S )zxCheck if the file should be excluded.

        Check if 'options.exclude' contains a pattern matching filename.
        FT)r  excluder  r  basenamer  r  r  )ra   r  r  r  s       r7   r  zStyleGuide.excludedJ	  s    
 |# 	57##H--(DL$899 	4 	6w||FH55H7??8,,h(<===r9   c                     t                    dk     r't          fd| j        j        D                       rdS                     | j        j                  o                    | j        j                   S )zCheck if the error code should be ignored.

        If 'options.select' contains a prefix of the error code,
        return False.  Else, if 'options.ignore' contains a prefix of
        the error code, return True.
        r   c              3   B   K   | ]}|                               V  d S r_  r`  )r5   r6   r   s     r7   r8   z)StyleGuide.ignore_code.<locals>.<genexpr>`	  sC       !? !?%& "#d!3!3 !? !? !? !? !? !?r9   F)r}   re  r  r  r   r  )ra   r   s    `r7   ri  zStyleGuide.ignore_codeY	  s     t99q==S !? !? !? !?*.,*=!? !? !? ? ?=5 344 9OODL$7888	:r9   c                      g }t           |                                         D ]B\  }}|\  }}t           fd|D                       r|                    |j        ||f           Ct          |          S )zGet all the checks for this category.

        Find all globally visible functions where the first argument
        name starts with argument_name and which contain selected tests.
        c              3   H   K   | ]}|o                     |           V  d S r_  )ri  )r5   r   ra   s     r7   r8   z(StyleGuide.get_checks.<locals>.<genexpr>o	  s9      KKT7!1!1$!7!78KKKKKKr9   )r[   r  re  r   r  r  )ra   argument_namechecksr]   attrsr^   r_   s   `      r7   r  zStyleGuide.get_checksf	  s     #M288:: 	= 	=LE5!MUDKKKKUKKKKK =u~ud;<<<f~~r9   r_  )NNr   )r  rb  rc  re   rg   r  r  r  r  r  ri  r  rL   r9   r7   r  r    s        77# # #J# # # #
   $N N N N9 9 90> > > >: : :    r9   r  c                 H   t          | |d          }g d|_        |                    ddddd	           |                    d
dddd	           |                    ddddd	           |                    dddd           |                    ddt          d           |                    dddd           |                    ddd d!           |                    d"dd d#t          z             |                    d$dd%&           |                    d'dd(&           |                    d)dd*&           |                    d+dd,&           |                    d-d.d/t
          d01           |                    d2d.d/d3d41           |                    d5d.d/t          d61           |                    d7dd8&           |                    d9d:d;d<           |                    d=dd>&           |                    d?          }|                    d@ddA&           |S )Bz"Create the parser for the program.z%prog [options] input ...)progversionusage)r  r  r  r  zmax-line-lengthzmax-doc-lengthzindent-sizezhang-closingr  r   r  z	show-pep8zshow-source
statisticsr   z-vz	--verboser   r  z(print status messages, or debug with -vv)r   actionhelpz-qz--quietz+report only file names, or nothing with -qqz-rz--repeatT
store_truez1(obsolete) show all occurrences of the same errorz--firststore_falser  z#show first occurrence of each error)r  destr  z	--excluder  z[exclude files or directories which match these comma separated patterns (default: %default)metavarr   r  z
--filenamez*.pyzjwhen parsing directories, only check filenames matching these comma separated patterns (default: %default)z--selectr  rZ   z&select errors and warnings (e.g. E,W6)z--ignorez2skip errors and warnings (e.g. E4,W) (default: %s)z--show-sourcezshow source code for each error)r  r  z--show-pep8z3show text of PEP 8 for each error (implies --first)z--statisticszcount errors and warningsz--countzgprint total number of errors and warnings to standard error and set exit code to 1 if total is not nullz--max-line-lengthr  r  z3set maximum allowed line length (default: %default))r   r  r   r  z--max-doc-lengthNzSset maximum allowed doc line length and perform these checks (unchecked if not set)z--indent-sizez9set how many spaces make up an indent (default: %default)z--hang-closingzNhang closing bracket instead of matching indentation of opening bracket's linez--formatr   r   z.set the error format [default|pylint|<custom>]z--diffzSreport changes only within line number ranges in the unified diff received on STDINzTesting Optionsz--benchmarkzmeasure processing speed)r   config_options
add_optionDEFAULT_EXCLUDEr  MAX_LINE_LENGTHINDENT_SIZEadd_option_group)r  r  r  rl   s       r7   
get_parserr  t	  sw   tW ;= = =FF F FF dK7E  G G G
dIqH  J J J
dJ\N  P P P
iH@  B B B
k:J  K K K lJ1  2 2 2 j(BC  E E E
j(B+-;<  = = = ol<  > > >
mL/  0 0 0 n\6  8 8 8
i/  0 0 0 )s-1  2 2 2 (uc"A  B B B oE3)1  2 2 2 &|C  D D D j(IK  M M M
h|@  A A A ##$566E	]<4  6 6 6Mr9   c           
      l   t          j                    }| j        }t          j        }t
          r\t          j                            t
                    r8| j        rt          dt
          z             |
                    t
                     |o;t          j                            t          j                            |                    x}|rf|
                    fdt          D                       r}| j        rt          dz             n$t          j                                      \  }|f|rMt          j                            |          r.| j        rt          d|z             |
                    |           d}|                    |j                  r|j        }n+|                    d          rd}t#          j        d           |r`d |j        D             }	|                    g           \  }
}|                    |          D ]}|                    d	d
          |j        vrt          d|z             3| j        dk    r7t          d                    ||                    ||                               |                    d
d	          }|	|         }|dv r|                    ||          }nG|dv r|                    ||          }n,|                    ||          }|dk    rt9          ||          }t;          |
||           |                    ||
          \  } }| S )a{  Read and parse configurations.

    If a config file is specified on the command line with the
    "--config" option, then only it is used for configuration.

    Otherwise, the user configuration (~/.config/pycodestyle) and any
    local configurations in the current directory or above will be
    merged together (in that order) using the read method of
    ConfigParser.
    zuser configuration: %sc              3   X   K   | ]$}t           j                            |          V  %d S r_  )r  r  r  )r5   fnr  s     r7   r8   zread_config.<locals>.<genexpr>	  s3      IIBrw||FB//IIIIIIr9   zlocal configuration: in %szcli configuration: %sNpep8z0[pep8] section is deprecated. Use [pycodestyle].c                 6    i | ]}|j         |j        p|j        S rL   )r  r   r  r5   os     r7   rk  zread_config.<locals>.<dictcomp>	  s%    NNNaqvqv1NNNr9   r  r   z  unknown option '%s' ignoredr   z	  {} = {})r  r  )r  r  r  )rU   )configparserRawConfigParserconfigr  curdirUSER_CONFIGr  isfiler   r   r  r  commonprefixPROJECT_CONFIGr   has_sectionr  warningswarnoption_list
parse_argsr  r4   r  r   r   getint
getbooleanr  setattr)r  r_   r  r  r  cli_conf	local_dirtailpycodestyle_sectionr  new_optionsr  optnormalized_optopt_typer  r  s                   @r7   read_configr  	  sW    )++F~H	I !rw~~k22 !? 	:*[8999K   HRW__RW-A-A$-G-GHHHFT
 /;;IIII.IIIII 	I =2V;<<<v..  /  BGNN8,, ? 	6)H4555H&+&& J$k			F	#	# J$HIII GNN6;MNNN #--b11b >>"566 	8 	8C{{3$$F,AAA5;<<<""k(()/4G)M)MO O P P P [[c22N">2H+++&93??:::))*=sCC

#6<<!Y..+E9==EK7777 ))'+)FF"Nr9   Fc           	         |st                      }|                    d          sT|                    dd|j        dd                    |j                  d          }|                    dd|d	
           | s|sg } |                    |           \  }}d|_        |||_	        |r@|s>|j
        st          d t          D                       rdg}n|                    d           t          ||| |          }|o|j        dk    ot           |_        t#          |j                  |_        t'          |j                  |_        t#          |j                  |_        t#          |j                  |_        |j
        rOt.          |_        t1                      }t3          ||j        |d                   |_        t7          |j                  }||fS )zProcess options passed either via arglist or command line args.

    Passing in the ``config_file`` parameter allows other tools, such as
    flake8 to specify their own options to be processed in pycodestyle.
    z--configConfigurationz'The project options are read from the [z] section of the tox.ini file or the setup.cfg file located in any parent folder of the path(s) being processed.  Allowed options are: z, r  )descriptionr  zuser config file locationr  Nc              3   T   K   | ]#}t           j                            |          V  $d S r_  )r  r  exists)r5   rO   s     r7   r8   z"process_options.<locals>.<genexpr>
  sD       ; ;#'  "w~~d33 ; ; ; ; ; ;r9   zinput not specifiedr   r   )r  
has_optionr  r  r  r  r  r  r  r   r  re  r  r	  r  r  r  _parse_multi_optionsr  r  r  r  r  r  r  r  r  r  )	r  r  r  r  r   rl   r  r_   r  s	            r7   r  r  	  s     Z(( ;'' [[[$))F$9::::< ( > >
 	V[9 	 	; 	; 	;  :  ''00OWdG ! 0$ 0< 	03 ; ;+9; ; ; ; ; 	05DDLL.///'4&99G!Ggmq&8GZG+G,<==G%go66GO)'.99GN)'.99GN| .%!!!,UG4Dd1g!N!Ng,--D=r9   r   c                 H    | rd |                      |          D             S | S )zgSplit and strip and discard empties.

    Turns the following:

    A,
    B,

    into ["A", "B"]
    c                 ^    g | ]*}|                                 |                                 +S rL   )r   r  s     r7   rQ   z(_parse_multi_options.<locals>.<listcomp>>
  s-    KKKaK		KKKr9   )r   )r  split_tokens     r7   r  r  3
  s1      KK7==#=#=KKKKr9   c                     ddl } 	 |                      | j        d            n# t          $ r Y nw xY wt          d          }|j        }|                                }|j        r|                                 |j        r|	                                 |j
        rQ|j        r4t          j                            t          |j
                  dz              t          j        d           dS dS )z.Parse options and run checks on Python source.r   Nc                 *    t          j        d          S )Nr   )r  exit)signumframes     r7   <lambda>z_main.<locals>.<lambda>I
  s    CHQKK r9   T)r  rx   r   )signalSIGPIPEAttributeErrorr  r  r  r  r  	benchmarkr  rl  r  r  stderrwriter   r  )r#  style_guider  r!  s       r7   _mainr*  C
  s   MMMfn&G&GHHHH    ---K!G$$&&F "!!! !    = 	>JS!455<=== s   # 
00__main__r_  )Nr  )T)NFNNN)r   )re   rC  r  rR   r  r   r  rc  r  rr  r   r  r   	functoolsr   optparser   r  callabler,  r	   __version__r  r  platformr  
expanduserr  r  getenvImportErrorr  r  r   r  r  r  rK  	frozensetr   kwlistr5  r4  r2  r  r6  r3  r1  r   r   INDENTDEDENTr  r   
ERRORTOKENr0  r  rJ  rj   rc   r   r   r>  r  r  r  r   r  rm  r  r   r   r   rp  rd  r  r   r  r/  r[   rW   rh   rr   rv   r   r   r   r   r   r   r   r   r   r  r  r  r<  r@  rI  rR  rV  rh  ru  r{  r}  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  rn  r   r   r  r  r  r  r  rl  r  r  re  r  r  r  r  r  r  r  r  r*  r  rL   r9   r7   <module>r9     s!  8 *       				  				 				 



                ! ! ! ! ! ! 	7"":t4455 	# "	("344H;9	
|wg(():;;gllBI'((KBG,>,>{,K,K
 
    KKK * 	   <5 
 Y00011
9W^wi/00:=)77788	???@@%++,L,L,LMM i !) !) !) * *  Yy!!

)X[("23
4
4mmX_ho>??!!8#3X5H"IJJLLLrz+&&"*.//"*\**(bj)KLL )rz*>?? $"* &F G G # %1 2 2 RZ4   
2TYYx5H5HHIIIJJrz-((RZEFF
!rz"9:: 'RZ(NOO $.BJ " " C " " "    
% 
% ! rzJKKRZ.. w*M,N&KK355M5N[B
?
?B B B   . M M M& D D D < < <* D D D  H H HJ :  :  :F R/ R/ R/j > > >@ G G G. D D D, &1 &1 &1R JE JE JEZ % % %P H H H. ] ] ]@ J J J$ > > >B ) ) )X = = =& 31 31 31l =* =* =*@ % % %V 	*++ii.A.AA  ! ! !4 B B B:   D !7 !7 !7H J J J* 
 
 
* = = =  ` ` `F 8 8 8x ,  ,  , h! ! !F F F
 yy~~jbj!5rt<<CDD  &	; 	; 	;   : #%)    $C C C C  L L L`. `. `. `. `. `. `. `.F	W, W, W, W, W, W, W, W,t       3  3  3  3  3 Z 3  3  3 l
? 
? 
? 
? 
? 
? 
? 
?F F F F F F F FR "; > > > >BG G GT AE)-1 1 1 1h      6 z	EGGGGG s   >A)C( (C21C2