File: //home/arjun/projects/env/lib/python3.10/site-packages/pyflakes/__pycache__/api.cpython-310.pyc
o
we� � @ s� d Z ddlZddlZddlZddlZddlZddlmZmZ ddlm Z
g d�Ze�d�Z
ddd�Zdd d
�Zdd� Zd
d� Zdd� Zdd� Zdd� Zddd�ZdS )z,
API for the command-line I{pyflakes} tool.
� N)�checker�__version__)�reporter)�check� checkPath�checkRecursive�iterSourceCode�mains# ^#!.*\bpython(3(\.\d+)?|w)?[dmu]?\sc
C s� |du rt �� }z tj| |d�}W n1 ty3 } z|�||jd |j|j|j � W Y d}~dS d}~w t
yB |�|d� Y dS w tj
||d�}|jjdd� d� |jD ]}|�|� qVt|j�S ) a�
Check the Python source given by C{codeString} for flakes.
@param codeString: The Python source to check.
@type codeString: C{str}
@param filename: The name of the file the source came from, used to report
errors.
@type filename: C{str}
@param reporter: A L{Reporter} instance, where errors and warnings will be
reported.
@return: The number of warnings emitted.
@rtype: C{int}
N)�filenamer � zproblem decoding sourcec S s | j S �N)�lineno)�m� r �E/home/arjun/projects/env/lib/python3.10/site-packages/pyflakes/api.py�<lambda>0 s zcheck.<locals>.<lambda>)�key)�modReporter�_makeDefaultReporter�ast�parse�SyntaxError�syntaxError�argsr
�offset�text� Exception�unexpectedErrorr �Checker�messages�sort�flake�len)�
codeStringr
r �tree�e�w�warningr r r r s"