Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/pylint/checkers/__pycache__/dataclass_checker.cpython-39.pyc
Ðазад
a n�h� � @ s� d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl m Z mZ ddlm Z er`ddlmZ d d d�dd �Zddd d�dd�ZG dd� de �Zddd�dd�ZdS )z#Dataclass checkers for Python code.� )�annotations)� TYPE_CHECKING)�nodes)�DATACLASS_MODULES)�BaseChecker�utils)� INFERENCE)�PyLinterznodes.Module�bool��node�returnc C s | j tv S )z=Utility function to check if node is from dataclasses_module.)�namer )r � r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/pylint/checkers/dataclass_checker.py�_is_dataclasses_module s r znodes.Name | nodes.Attribute�str)r � check_withr c C s( t | tj�rt| j�|kS t| j�|kS )zdUtility function to check either a Name/Attribute node's name/attrname with a given string. )� isinstancer �Namer r �attrname)r r r r r �_check_name_or_attrname_eq_to s r c @ sX e Zd ZdZdZddiZe�d�ddd�d d ��Zddd�dd�Z dddd �dd�Z dS )�DataclassCheckerzoChecker that detects invalid or problematic usage in dataclasses. Checks for * invalid-field-call � dataclassZE3701)zInvalid usage of field(), %s�invalid-field-callz�The dataclasses.field() specifier should only be used as the value of an assignment within a dataclass, or within the make_dataclass() function.r z nodes.Call�Noner c C s | � |� d S �N)�_check_invalid_field_call)�selfr r r r � visit_call6 s zDataclassChecker.visit_callc C s� t |jtjtjf�sdS t|jd�s(dS t�|j�}t |tj�rLt |� � �sPdS |j}|rtt |tjtj f�st|j}qVt |tj �r�| �||� dS |r�|js�| jd|dtd� dS t |jtj�r�||jjks�| jd|dtd� dS )af Checks for correct usage of the dataclasses.field() specifier in dataclasses or within the make_dataclass() function. Emits message when field() is detected to be used outside a class decorated with @dataclass decorator and outside make_dataclass() function, or when it is used improperly within a dataclass. N�fieldr �zFit should be used within a dataclass or the make_dataclass() function.�r �argsZ confidence)z;it should be the value of an assignment within a dataclass.)r �funcr r � Attributer r � safe_infer�FunctionDefr �root�parent�ClassDef�Call�%_check_invalid_field_call_within_call�is_dataclass�add_messager � AnnAssign�value)r r � inferred_func� scope_noder r r r : s>