관리-도구
편집 파일: code_style.cpython-311.pyc
� �܋f2 � �� � d dl mZ d dlZd dlmZmZmZmZ d dlm Z d dl mZmZ d dl mZmZ d dlmZ erd dlmZ ej d k rd d lmZ nd d lmZ G d� de� � Zdd�ZdS )� )�annotationsN)� TYPE_CHECKING�Tuple�Type�cast)�nodes)�BaseChecker�utils)�only_required_for_messages� safe_infer)� INFERENCE)�PyLinter)� � )� TypeGuardc �^ � e Zd ZdZdZddddddd d ifd�Zdd dddd�ffZd.d�Z ed� � d/d�� � Z ed� � d0d�� � Z ed� � d1d�� � Z ed� � d2d �� � Zd/d!�Z d2d"�Zed3d(�� � Zed4d*�� � Z ed� � d5d,�� � Zd-S )6�CodeStyleCheckeram Checkers that can improve code consistency. As such they don't necessarily provide a performance benefit and are often times opinionated. Before adding another checker here, consider this: 1. Does the checker provide a clear benefit, i.e. detect a common issue or improve performance => it should probably be part of the core checker classes 2. Is it something that would improve code consistency, maybe because it's slightly better with regard to performance and therefore preferred => this is the right place 3. Everything else should go into another extension � code_style)z<Consider using namedtuple or dataclass for dictionary values�&consider-using-namedtuple-or-dataclasszUEmitted when dictionary values can be replaced by namedtuples or dataclass instances.)z0Consider using an in-place tuple instead of list�consider-using-tuplez�Only for style consistency! Emitted where an in-place defined ``list`` can be replaced by a ``tuple``. Due to optimizations by CPython, there is no performance benefit from it.)zUse '%s' instead�consider-using-assignment-exprz�Emitted when an if assignment is directly followed by an if statement and both can be combined by using an assignment expression ``:=``. Requires Python 3.8 and ``py-version >= 3.8``.z+Use '%s' to do an augmented assign directly�consider-using-augmented-assignz�Emitted when an assignment is referring to the object that it is assigning to. This can be changed to be an augmented assign. Disabled by default!�default_enabledF)�R6101�R6102�R6103�R6104zmax-line-length-suggestions�intr z<int>z�Max line length for which to sill emit suggestions. Used to prevent optional suggestions which would get split by a code formatter (e.g., black). Will default to the setting for ``max-line-length``.)�type�default�metavar�help�return�Nonec � � | j j j }|dk | _ | j j j p| j j j | _ d S )N)r � )�linter�config� py_version� _py38_plus�max_line_length_suggestions�max_line_length�_max_length)�selfr) s �m/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/pylint/extensions/code_style.py�openzCodeStyleChecker.openZ sD � ��[�'�2� �$��.����K��:� 2��{�!�1� ���� r �node� nodes.Dictc �0 � | � |� � d S �N)�)_check_dict_consider_namedtuple_dataclass�r. r2 s r/ � visit_dictzCodeStyleChecker.visit_dictb s � ��6�6�t�<�<�<�<�<r1 r � nodes.Forc � � t |j t j � � r| � d|j �� � d S d S �Nr �r2 �� isinstance�iterr �List�add_messager7 s r/ � visit_forzCodeStyleChecker.visit_forf �G � ��d�i���,�,� E����3�$�)��D�D�D�D�D� E� Er1 �nodes.Comprehensionc � � t |j t j � � r| � d|j �� � d S d S r; r= r7 s r/ �visit_comprehensionz$CodeStyleChecker.visit_comprehensionk rC r1 r �nodes.Ifc �B � | j r| � |� � d S d S r5 )r* �%_check_consider_using_assignment_exprr7 s r/ �visit_ifzCodeStyleChecker.visit_ifp s0 � ��?� =��6�6�t�<�<�<�<�<� =� =r1 c �� � t |j t j t j f� � r$t |j j t j � � sdt |j t j � � rCt |j j t j � � rt j |j j d� � sdS t |j � � dk �r�t d� |j D � � � � �r�t t t j t f }t# � � }|j D ]�\ }}t% t j |� � }|j D ]�\ }}t) |� � |� � � f}||v r�-t- |� � }t |t j � � r|� � � dk s dS |� |� � ����g } |j D ]P\ }}t% t j |� � }| � t7 d� |j D � � � � � � �Qt# | d � � } | dd� D ]}| � |� � �| sdS | � d|� � � dS t |j � � dk r�t d � |j D � � � � r�t |j d d j � � }|dk rdS |j dd� D ] \ }}t |j � � |k r dS �!|j D ]&\ }}t d� |j D � � � � r dS �'| � d|� � � dS dS dS )zFCheck if dictionary values can be replaced by Namedtuple or Dataclass.�FinalN� c 3 �P K � | ]!\ }}t |t j � � V � �"d S r5 �r>