Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/pylint/checkers/base/__pycache__/function_checker.cpython-39.pyc
Ðазад
a n�h� � @ sT d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl m Z G dd� de �Zd S ) z!Function checker for Python code.� )�annotations)�chain)�nodes)�utils)� _BasicCheckerc @ sr e Zd ZdZddiZe�d�ddd�dd ��Ze�d�d dd�dd��Zddd�d d�Z e dddd�dd��ZdS )�FunctionCheckerz=Check if a function definition handles possible side effects.ZW0135)z3The context used in function %r will not be exited.�(contextmanager-generator-missing-cleanupz^Used when a contextmanager is used inside a generator function and the cleanup is not handled.r znodes.FunctionDef�None)�node�returnc C s | � |� d S �N��/_check_contextmanager_generator_missing_cleanup��selfr � r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/pylint/checkers/base/function_checker.py�visit_functiondef s z!FunctionChecker.visit_functiondefznodes.AsyncFunctionDefc C s | � |� d S r r r r r r �visit_asyncfunctiondef! s z&FunctionChecker.visit_asyncfunctiondefc C s� t |�tj��}|sdS t t�dd� |D ���}|s8dS |D ]^}|jD ]R\}}|du rXqFtt� |�dd�}t |tj�sxqF| �||�rF| j d||jfd� qFq<dS )a Check a FunctionDef to find if it is a generator that uses a contextmanager internally. If it is, check if the contextmanager is properly cleaned up. Otherwise, add message. :param node: FunctionDef node to check :type node: nodes.FunctionDef Nc s s | ]}|� tj�V qd S r )�nodes_of_classr �Yield)�.0� with_noder r r � <genexpr>6 s zRFunctionChecker._check_contextmanager_generator_missing_cleanup.<locals>.<genexpr>�parentr )r �args)�listr r �Withr � from_iterable�items�getattrr � safe_infer� isinstance�FunctionDef�"_node_fails_contextmanager_cleanupZadd_message�name)r r Z with_nodes�yield_nodesr �callZheldZ inferred_noder r r r % s. ���z?FunctionChecker._check_contextmanager_generator_missing_cleanupzlist[nodes.Yield]�bool)r r&