Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/pylint/checkers/__pycache__/dunder_methods.cpython-39.pyc
Ðазад
a n�hD � @ s� d dl mZ d dlmZ d dlmZmZ d dlmZ d dl m Z d dlmZ d dl mZmZ d dlmZ erxd d lmZ G d d� de �Zdd d�dd�ZdS )� )�annotations)� TYPE_CHECKING)�Instance�nodes)�UninferableBase)�BaseChecker)� safe_infer)�DUNDER_METHODS�)UNNECESSARY_DUNDER_CALL_LAMBDA_EXCEPTIONS)�HIGH)�PyLinterc @ sh e Zd ZdZdZddiZdZdd�dd �Zed dd�d d��Z ed d dd�dd��Z ddd�dd�ZdS )�DunderCallCheckera� Check for unnecessary dunder method calls. Docs: https://docs.python.org/3/reference/datamodel.html#basic-customization We exclude names in list pylint.constants.EXTRA_DUNDER_METHODS such as __index__ (see https://github.com/pylint-dev/pylint/issues/6795) since these either have no alternative method of being called or have a genuine use case for being called manually. Additionally, we exclude classes that are not instantiated since these might be used to access the dunder methods of a base class of an instance. We also exclude dunder method calls on super() since these can't be written in an alternative manner. �unnecessary-dunder-callZC2801)z)Unnecessarily calls dunder method %s. %s.r ziUsed when a dunder method is manually called instead of using the corresponding function/method/operator.� �None)�returnc C s6 i | _ t�� D ]"\}}|| jjjkr| j �|� qd S �N)�_dunder_methodsr �items�linter�config� py_version�update)�selfZ since_versZdunder_methodsr r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/pylint/checkers/dunder_methods.py�open/ s zDunderCallChecker.openznodes.NodeNG�bool)�noder c C sN | j }|durJt|tj�r2|j�d�r2|j�d�s>t�|| �rBdS |j }qdS )zACheck if dunder method call is within a dunder method definition.N�__TF) �parent� isinstancer �FunctionDef�name� startswith�endswithr �is_lambda_rule_exception)r r r r r �within_dunder_or_lambda_def5 s � � � �z-DunderCallChecker.within_dunder_or_lambda_def)�ancestorr r c C s t | tj�o|jjtv S r )r r �Lambda�func�attrnamer )r'