o
    h=                     @  sz  d Z ddlm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
ZddlmZ ddlmZ eeZi dd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)i d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWZG dXdY dYejjZdS )Zz8Plugin built-in to Flake8 to treat pyflakes as a plugin.    )annotationsN)Any)	Generator)utils)OptionManagerUnusedImportF401ImportShadowedByLoopVarF402ImportStarUsedF403LateFutureImportF404ImportStarUsageF405ImportStarNotPermittedF406FutureFeatureNotDefinedF407PercentFormatInvalidFormatF501PercentFormatExpectedMappingF502PercentFormatExpectedSequenceF503 PercentFormatExtraNamedArgumentsF504PercentFormatMissingArgumentF505$PercentFormatMixedPositionalAndNamedF506$PercentFormatPositionalCountMismatchF507!PercentFormatStarRequiresSequenceF508'PercentFormatUnsupportedFormatCharacterF509StringDotFormatInvalidFormatF521"StringDotFormatExtraNamedArgumentsF522'StringDotFormatExtraPositionalArgumentsF523StringDotFormatMissingArgumentF524StringDotFormatMixingAutomaticF525FStringMissingPlaceholdersF541MultiValueRepeatedKeyLiteralF601MultiValueRepeatedKeyVariableF602%TooManyExpressionsInStarredAssignmentF621TwoStarredExpressionsF622AssertTupleF631	IsLiteralF632InvalidPrintSyntaxF633IfTupleF634BreakOutsideLoopF701ContinueOutsideLoopF702YieldOutsideFunctionF704ReturnOutsideFunctionF706F707F721F722F811F821F822F823F831F841F842F901)DefaultExceptNotLastDoctestSyntaxErrorForwardAnnotationSyntaxErrorRedefinedWhileUnusedUndefinedNameUndefinedExportUndefinedLocalDuplicateArgumentUnusedVariableUnusedAnnotationRaiseNotImplementedc                      sf   e Zd ZU dZdZg Zded< g Zded< d fddZe	dddZ
e	dddZdddZ  ZS )FlakesCheckerz=Subclass the Pyflakes checker to conform with the flake8 API.Fz	list[str]include_in_doctestexclude_from_doctesttreeast.ASTfilenamestrreturnNonec                   s~   t | j}fdd| jD }|rd}| jD ]  dkr3 r3d} fdd|D }|r3d}qt j||d dS )	z=Initialize the PyFlakes plugin with an AST tree and filename.c                   s"   g | ]}|d kr  |r|qS ) 
startswith.0include)rf    M/var/www/html/ai/venv/lib/python3.10/site-packages/flake8/plugins/pyflakes.py
<listcomp>N   s
    z*FlakesChecker.__init__.<locals>.<listcomp>Trj   Fc                   s   g | ]	}|  r|qS rp   rk   rm   )excluderp   rq   rr   Y   s    )rf   withDoctestN)r   normalize_pathwith_doctestrb   rc   rl   super__init__)selfrd   rf   rv   included_byoverlapped_by	__class__)rs   rf   rq   rx   J   s"   



zFlakesChecker.__init__parserr   c              	   C  sZ   |j ddddd |j dddddd	 |j d
ddddddd |j dddddddd dS )z:Register options for PyFlakes on the Flake8 OptionManager.z
--builtinsTz&define more built-ins, comma separated)parse_from_configcomma_separated_listhelpz
--doctestsF
store_truez!also check syntax of the doctests)defaultactionr   r   z--include-in-doctestrj   rb   z Run doctests only on these files)r   destr   r   normalize_pathsr   z--exclude-from-doctestrc   z&Skip these files when running doctestsN)
add_option)clsr~   rp   rp   rq   add_optionsd   s>   	
zFlakesChecker.add_optionsoptionsargparse.Namespacec                 C  s  |j r| j|j | _|j| _|js|jrtd g }|jD ]}|dkr&q|	t
jddfs8|d|  q|| qt|| _g }|jD ]}|dkrPqI|	t
jddfsb|d|  qI|| qIt|| _t| j| j}|rt|ddS )z0Parse option values from Flake8's OptionManager.zi--include-in-doctest / --exclude-from-doctest will be removed in a future version.  see PyCQA/flake8#1747rj   z./z~/z was specified in both the include-in-doctest and exclude-from-doctest options. You are not allowed to specify it in both for doctesting.N)builtinsbuiltInsuniondoctestsrv   rb   rc   LOGwarningrl   ossepappendr   r   setintersection
ValueError)r   r   included_filesincluded_fileexcluded_filesexcluded_fileinc_excrp   rp   rq   parse_options   s>   


zFlakesChecker.parse_options6Generator[tuple[int, int, str, type[Any]], None, None]c              	   c  sN    | j D ] }t|dd}|j|dtt|jd|j|j	 |j
fV  qdS )zRun the plugin.colr   z{} {}F999N)messagesgetattrlinenoformatFLAKE8_PYFLAKES_CODESgettype__name__messagemessage_argsr}   )ry   r   r   rp   rp   rq   run   s   

zFlakesChecker.run)rd   re   rf   rg   rh   ri   )r~   r   rh   ri   )r   r   rh   ri   )rh   r   )r   
__module____qualname____doc__rv   rb   __annotations__rc   rx   classmethodr   r   r   __classcell__rp   rp   r|   rq   ra   C   s   
 "+ra   )r   
__future__r   argparseastloggingr   typingr   r   pyflakes.checkerpyflakesflake8r   flake8.options.managerr   	getLoggerr   r   r   checkerCheckerra   rp   rp   rp   rq   <module>   s    
	
 !"#1