Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/pylint/checkers/__pycache__/method_args.cpython-39.pyc
Ðазад
a n�h� � @ s� d Z ddlmZ ddlmZ ddlZddlmZmZmZ ddl m Z mZ ddlm Z erdddlmZ G d d � d e �Zddd �dd�ZdS )z#Variables checkers for Python code.� )�annotations)� TYPE_CHECKINGN)� arguments�bases�nodes)�BaseChecker�utils)� INFERENCE)�PyLinterc @ sn e Zd ZdZdZddd�Zdddd d d�ffZe�dd �ddd�dd��Z ddd�dd�Z ddd�dd�ZdS )�MethodArgsCheckerzpBaseChecker for method_args. Checks for * missing-timeout * positional-only-arguments-expected Zmethod_args)zTMissing timeout argument for method '%s' can cause your program to hang indefinitely�missing-timeoutz�Used when a method needs a 'timeout' parameter in order to avoid waiting for a long time. If no timeout is specified explicitly the default value is used. For example for 'requests' the program will never time out (i.e. hang indefinitely).)zI`%s()` got some positional-only arguments passed as keyword arguments: %s�"positional-only-arguments-expectedz�Emitted when positional-only arguments have been passed as keyword arguments. Remove the keywords for the affected arguments in the function call.)ZW3101ZE3102ztimeout-methods)zrequests.api.deletezrequests.api.getzrequests.api.headzrequests.api.optionszrequests.api.patchzrequests.api.postzrequests.api.putzrequests.api.request�csvz<comma separated list>zzList of qualified names (i.e., library.method) which require a timeout parameter e.g. 'requests.api.get,requests.api.post')�default�type�metavar�helpr r z nodes.Call�None)�node�returnc C s | � |� | �|� d S �N)�_check_missing_timeout�)_check_positional_only_arguments_expected)�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/method_args.py� visit_callD s zMethodArgsChecker.visit_callc C s� t �|j�}tj�|�}|r�|�� s�t|tj tj tjf�r�|� � | jjjv r�dd� |jD �}|�|j� d|vr�| jd||j�� ftd� dS )z�Check if the call needs a timeout parameter based on package.func_name configured in config.timeout_methods. Package uses inferred node in order to know the package imported. c S s g | ] }|j �qS r ��arg)�.0�keywordr r r � <listcomp>[ � z<MethodArgsChecker._check_missing_timeout.<locals>.<listcomp>�timeoutr �r �argsZ confidenceN)r � safe_infer�funcr ZCallSiteZ from_callZhas_invalid_keywords� isinstancer �FunctionDef�ClassDefr � UnboundMethodZqname�linter�configZtimeout_methods�keywords�extend�keyword_arguments�add_message� as_stringr )r r �inferredZ call_siter0 r r r r K s* ����� �z(MethodArgsChecker._check_missing_timeoutc s� t �|j�}t|tjtjf�r&|j}qt|tj �r:|j js>dS |j jrJdS dd� |j jD �� � fdd�|j D �}|sxdS | jd||j�� d�dd� |D ��ftd � dS ) z~Check if positional only arguments have been passed as keyword arguments by inspecting its method definition. Nc S s g | ] }|j �qS r )�name)r �ar r r r! s r"