관리-도구
편집 파일: special_methods_checker.cpython-311.pyc
� �܋f; � � � d Z ddlmZ ddlmZ ddlZddlmZmZmZ ddl m Z ddlmZ ddl mZ dd lmZmZmZmZmZmZ dd lmZ dZ ddd�Z G d� de� � ZdS )z5Special methods checker and helper function's module.� )�annotations)�CallableN)�bases�nodes�util)�InferenceContext)�InferenceResult)�BaseChecker)� PYMETHODS�SPECIAL_METHODS_PARAMS�decorated_with�is_function_body_ellipsis�only_required_for_messages� safe_infer)�PyLinter�__next__�node�nodes.FunctionDef�caller�context�InferenceContext | None�return�InferenceResult | Nonec � � | � ||�� � }t |� � }n"# t j $ r Y dS t $ r Y dS w xY w t |� � dS # t j $ r Y dS t $ r |cY S w xY w)z�Safely infer the return value of a function. Returns None if inference failed or if there is some ambiguity (more than one node has been inferred). Otherwise, returns inferred value. )r N)�infer_call_result�next�astroid�InferenceError� StopIteration)r r r �inferit�values ��/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/pylint/checkers/classes/special_methods_checker.py�_safe_infer_call_resultr# s� � ���(�(���(�A�A���W� � �����!� � � ��t�t�� � � ��t�t�������W� � � ��t���!� � � ��t�t�� � � ��������s, �&) �A� A�A�A �A=�/A=�<A=c �� � � e Zd ZdZdZddde� d�ddd gifd dddd gifdddddddddddd� ZdG� fd�Z edddd d!d"d#d$d%d&d'd(d)� � dHd,�� � Z e Z dHd-�ZedId2�� � Z edJd3�� � ZedJd4�� � ZedJd5�� � ZedJd6�� � ZedJd7�� � ZedJd8�� � ZedJd9�� � ZdKd;�ZdKd<�ZdKd=�ZdKd>�ZdKd?�ZdKd@�ZdKdA�ZdKdB�ZdKdC�ZdKdD�ZdKdE�ZdKdF�Z � xZ!S )L�SpecialMethodsCheckerzOChecker which verifies that special methods are implemented correctly. �classesz__iter__ returns non-iterator�non-iterator-returnedzVUsed when an __iter__ method returns something which is not an iterable (i.e. has no `z ` method)� old_names)�W0234zold-non-iterator-returned-1)�E0234zold-non-iterator-returned-2z6The special method %r expects %s param(s), %d %s given�#unexpected-special-method-signaturez�Emitted when a special method was defined with an invalid number of parameters. If it has too few or too many, it might not work at all.)�E0235zbad-context-manager)z,__len__ does not return non-negative integer�invalid-length-returnedzPUsed when a __len__ method returns something which is not a non-negative integer)z__bool__ does not return bool�invalid-bool-returnedzAUsed when a __bool__ method returns something which is not a bool)z__index__ does not return int�invalid-index-returnedzGUsed when an __index__ method returns something which is not an integer)z__repr__ does not return str�invalid-repr-returnedzCUsed when a __repr__ method returns something which is not a string)z__str__ does not return str�invalid-str-returnedzBUsed when a __str__ method returns something which is not a string)z__bytes__ does not return bytes�invalid-bytes-returnedzAUsed when a __bytes__ method returns something which is not bytes)z__hash__ does not return int�invalid-hash-returnedzEUsed when a __hash__ method returns something which is not an integer)z4__length_hint__ does not return non-negative integer�invalid-length-hint-returnedzXUsed when a __length_hint__ method returns something which is not a non-negative integer)z__format__ does not return str�invalid-format-returnedzEUsed when a __format__ method returns something which is not a string)z&__getnewargs__ does not return a tuple�invalid-getnewargs-returnedzHUsed when a __getnewargs__ method returns something which is not a tuple)zB__getnewargs_ex__ does not return a tuple containing (tuple, dict)�invalid-getnewargs-ex-returnedzbUsed when a __getnewargs_ex__ method returns something which is not of the form tuple(tuple, dict)) �E0301�E0302�E0303�E0304�E0305�E0306�E0307�E0308�E0309�E0310�E0311�E0312�E0313�linterr r �Nonec �� �� t � � � |� � | j | j | j | j | j | j | j | j | j | j | j | j d�| _ d S )N)�__iter__�__len__�__bool__� __index__�__repr__�__str__� __bytes__�__hash__�__length_hint__� __format__�__getnewargs__�__getnewargs_ex__)�super�__init__�_check_iter� _check_len�_check_bool�_check_index�_check_repr� _check_str�_check_bytes�_check_hash�_check_length_hint� _check_format�_check_getnewargs�_check_getnewargs_ex� _protocol_map)�selfrE � __class__s �r"