B
    0zfz                 @   s   d dl Z d dlmZmZmZmZmZmZmZm	Z	m
Z
mZ d dlmZ d dlmZ yd dlmZ W n ek
r|   d dlZY nX dZeeZdZG dd	 d	eZdS )
    N)
AnyClassVarDictIterableIteratorListOptionalSequenceTupleType)
Eradicator)OptionManager)metadatazflake8-eradicatestdinc               @   s   e Zd ZU dZeZeZdZdZ	e
eeeef   ed< eej ee ddddZeeddd	d
ZeddddZeeeeeed  f  dddZee dddZdS )Checkerz)Flake8 plugin to find commented out code.zE800 Found commented out codeNoptions)file_tokenslinesreturnc             C   sl   || _ || _d| jji| _t | _| jj}| jj}|rN| jj	|
ddd n|rh| jj	|
ddd dS )z
        ``flake8`` plugin constructor.

        Arguments:
            file_tokens: all tokens for this file.
            lines: all file lines.

        
aggressive#T)Zextend_defaultFN)_file_tokens_linesr   Zeradicate_aggressive_optionsr   _eradicatorZeradicate_whitelistZeradicate_whitelist_extendZupdate_whitelistsplit)selftreer   r   	whitelistZwhitelist_ext r   S/home/ankuromar296_gmail_com/.local/lib/python3.7/site-packages/flake8_eradicate.py__init__+   s    
zChecker.__init__)parserr   c             C   sP   |j dddddd |j dddtjd	dd |j d
ddtjd	dd dS )z
        ``flake8`` api method to register new plugin options.

        See :class:`.Configuration` docs for detailed options reference.

        Arguments:
            parser: ``flake8`` option parser instance.

        z--eradicate-aggressiveFzIEnables aggressive mode for eradicate; this may result in false positives
store_trueT)defaulthelpactionZparse_from_configz--eradicate-whitelistzString of "#" separated comment beginnings to whitelist for eradicate. Single parts are interpreted as regex. OVERWRITING the default whitelist: {0}storez--eradicate-whitelist-extendzString of "#" separated comment beginnings to whitelist for eradicate. Single parts are interpreted as regex. Overwrites --eradicate-whitelist. EXTENDING the default whitelist: {0} N)
add_optionformatr   ZDEFAULT_WHITELIST)clsr"   r   r   r    add_optionsO   s(    zChecker.add_options)r   c             C   s
   || _ dS )z=Parses registered options for providing them to each visitor.N)r   )r*   r   r   r   r    parse_options~   s    zChecker.parse_optionsc             c   s*   x$|   D ]}|d| jt| fV  q
W dS )zRuns on each step of flake8.r   N)_lines_with_commented_out_code_error_templatetype)r   line_nor   r   r    run   s    zChecker.runc             c   sb   t dd | jD }|r^xDt| jD ]6\}}d| jj|| jd d}||kr$|d V  q$W dS )ao  
        Yield the physical line number that contain commented out code.

        This test relies on eradicate function to remove commented out code
        from a physical line.

        Physical lines might appear like commented code although they are part
        of a multi-line docstring (e.g. a `# noqa: DAR201` comment to suppress
        flake8 warning about missing returns in the docstring).
        To prevent this false-positive, the tokens of the physical line are
        checked for a comment. The eradicate function is only invokes,
        when the tokens indicate a comment in the physical line.
        c             s   s   | ]}|j tjkV  qd S )N)r/   tokenizeCOMMENT).0tokenr   r   r    	<genexpr>   s   z9Checker._lines_with_commented_out_code.<locals>.<genexpr> r   )r      N)anyr   	enumerater   joinr   Zfilter_commented_out_coder   )r   Zcomment_in_filer0   lineZfiltered_sourcer   r   r    r-      s    z&Checker._lines_with_commented_out_code) __name__
__module____qualname____doc__pkg_namenamepkg_versionversionr.   r   r   r   r   strr   __annotations__r   r2   	TokenInfor	   r!   classmethodr   r+   r,   r   r
   intr   r1   r   r-   r   r   r   r    r   !   s   
."r   )r2   typingr   r   r   r   r   r   r   r	   r
   r   Z	eradicater   Zflake8.options.managerr   	importlibr   importlib_metadataImportErrorrA   rD   rC   ZSTDINobjectr   r   r   r   r    <module>   s   0
