관리-도구
편집 파일: broad_try_clause.cpython-311.pyc
� �܋f� � �x � d Z ddlmZ ddlmZ ddlmZ ddlmZ erddl m Z G d� dej � � Zdd �Z dS )zELooks for try/except statements with too much code in the try clause.� )�annotations)� TYPE_CHECKING)�nodes)�checkers)�PyLinterc �F � e Zd ZdZdZddiZddddd d �ffZdd�Zdd�ZeZ dS )�BroadTryClauseCheckerz�Checks for try clauses with too many lines. According to PEP 8, ``try`` clauses shall contain the absolute minimum amount of code. This checker enforces a maximum number of statements within ``try`` clauses. �broad_try_clause�W0717)z%s�too-many-try-statementsz(Try clause contains too many statements.zmax-try-statements� �intz<int>z4Maximum number of statements allowed in a try clause)�default�type�metavar�help�try_node�"nodes.TryExcept | nodes.TryFinally�returnc �� � t |j � � }|j D ]V}t |t j t j t j t j f� � r|| � |� � z }�W|S �N) �len�body� isinstancer �For�If�While�With�_count_statements)�selfr �statement_count� body_nodes �s/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/pylint/extensions/broad_try_clause.pyr z'BroadTryClauseChecker._count_statements1 sg � ��h�m�,�,��!�� E� E�I��)�e�i���5�;�� �%S�T�T� E��4�#9�#9�)�#D�#D�D����� �node�Nonec �� � | � |� � }|| j j j k r7d|� d| j j j � �}| � d|j ||�� � d S d S )Nztry clause contains z statements, expected at most r )r% �args)r �linter�config�max_try_statements�add_message�lineno)r r% �try_clause_statements�msgs r# �visit_tryexceptz%BroadTryClauseChecker.visit_tryexcept: s� � � $� 6� 6�t� <� <�� �4�;�#5�#H�H�H�A�'<� A� A���+�>�A� A� � ���)�4�;�T�� � � � � � � I�Hr$ N)r r r r )r% r r r&