Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/pylint/checkers/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/pylint/checkers/__pycache__/logging.cpython-311.pyc

�

�܋f]?��Z�UdZddlmZddlZddlZddlmZddlZddlmZm	Z	ddl
mZddlm
Z
ddlmZdd	lmZdd
lmZejdkrddlmZnddlmZerdd
lmZdddddddd�Zded<hd�Zegd���Z	d2d3d"�ZGd#�d$e
j��Z d4d'�Z!d5d+�Z"d6d-�Z#d7d1�Z$dS)8z"Checker for use of Python logging.�)�annotationsN)�
TYPE_CHECKING)�bases�nodes)�InferenceResult)�checkers)�utils)�	infer_all)�MessageDefinitionTuple)��)�Literal)�PyLinter)�&Use %s formatting in logging functions�logging-not-lazya�Used when a logging statement has a call form of "logging.<logging method>(format_string % (format_args...))". Use another type of string formatting instead. You can use % formatting but leave interpolation to the logging function by passing the parameters as arguments. If logging-fstring-interpolation is disabled then you can use fstring formatting. If logging-format-interpolation is disabled then you can use str.format.)r�logging-format-interpolationa�Used when a logging statement has a call form of "logging.<logging method>(format_string.format(format_args...))". Use another type of string formatting instead. You can use % formatting but leave interpolation to the logging function by passing the parameters as arguments. If logging-fstring-interpolation is disabled then you can use fstring formatting. If logging-not-lazy is disabled then you can use % formatting as normal.)r�logging-fstring-interpolationa�Used when a logging statement has a call form of "logging.<logging method>(f"...")".Use another type of string formatting instead. You can use % formatting but leave interpolation to the logging function by passing the parameters as arguments. If logging-format-interpolation is disabled then you can use str.format. If logging-not-lazy is disabled then you can use % formatting as normal.)z;Unsupported logging format character %r (%#02x) at index %d�logging-unsupported-formatzWUsed when an unsupported format character is used in a logging statement format string.)z<Logging format string ends in middle of conversion specifier�logging-format-truncatedz`Used when a logging statement format string terminates before the end of a conversion specifier.)z,Too many arguments for logging format string�logging-too-many-argsz>Used when a logging format string is given too many arguments.)z.Not enough arguments for logging format string�logging-too-few-argsz=Used when a logging format string is given too few arguments.)�W1201�W1202�W1203�E1200�E1201�E1205�E1206z!dict[str, MessageDefinitionTuple]�MSGS>�info�warn�debug�error�fatal�warning�critical�	exception)z%sz%dz%fz%r��func�bases.BoundMethod�types�tuple[str, ...]�methods�return�boolc��t|tj��o=t|jtj��o|r|jj|vndo|r	|j|vndS)a~Determines if a BoundMethod node represents a method call.

    Args:
      func: The BoundMethod AST node to check.
      types: Optional sequence of caller type names to restrict check.
      methods: Optional sequence of method names to restrict check.

    Returns:
      true if the node represents a method call for the given type and
      method names, False otherwise.
    T)�
isinstance�astroid�BoundMethod�bound�Instance�name)r)r+r-s   �h/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/pylint/checkers/logging.py�is_method_callr8osf��	�4��,�-�-�	8��t�z�7�#3�4�4�	8�).�
8�T�Z�_��
%�
%�D�	8�&-�
6�T�Y�'�
!�
!�$�	�c��eZdZdZdZeZdddddd�fd	d
ddd
d
gdd�ffZd+d�Zd,d�Z	d-d�Z
d.d�Zd/d�Zd0d�Z
ed1d#���Zed2d%���Zd.d&�Zd3d)�Zd*S)4�LoggingCheckerz!Checks use of the logging module.�loggingzlogging-modules)r<�csvz<comma separated list>zcLogging modules to check that the string format arguments are in logging function parameter format.)�default�type�metavar�helpzlogging-format-style�old�choicez<old (%) or new ({)>�newztThe type of string formatting that logging methods do. `old` means using % formatting, `new` is for `{}` formatting.)r>r?r@�choicesrA�_�nodes.Moduler.�Nonec�8�t��|_|jjj}|jjj|_t|��|_i|_|D]A}|�	dd��}t|��dkr|d|j|d<�BdS)z?Clears any state left in this checker from last module checked.�.�rN)�set�_logging_names�linter�config�logging_modules�logging_format_style�
_format_style�_logging_modules�
_from_imports�rsplit�len)�selfrF�logging_mods�logging_mod�partss     r7�visit_modulezLoggingChecker.visit_module�s���
),������{�)�9��!�[�/�D��� #�L� 1� 1������'�	8�	8�K��&�&�s�A�.�.�E��5�z�z�A�~�~�/4�Q�x��"�5��8�,��	8�	8r9�node�nodes.ImportFromc��	|j|j}|jD]'\}}||kr|j�|p|���(dS#t
$rYdSwxYw)z;Checks to see if a module uses a non-Python logging module.N)rT�modname�namesrM�add�KeyError)rWr\�logging_name�module�as_names     r7�visit_importfromzLoggingChecker.visit_importfrom�s���	��-�d�l�;�L�#'�:�
?�
?�����\�)�)��'�+�+�G�,=�v�>�>�>��
?�
?���	�	�	��D�D�	���s�AA�
A�A�nodes.Importc�j�|jD]*\}}||jvr|j�|p|���+dS)z<Checks to see if this module uses Python's built-in logging.N)r`rSrMra)rWr\rdres    r7�visit_importzLoggingChecker.visit_import�sL��#�z�	;�	;�O�F�G���.�.�.��#�'�'��(9�6�:�:�:��	;�	;r9�
nodes.Callc����d��fd�}d�fd�}|��r
�jj}n|��\}}|sdS���|��dS)	z Checks calls to logging methods.r.r/c���t�jtj��o;t�jjtj��o�jjj�jvS�N)r1r)r�	Attribute�expr�Namer6rM)r\rWs��r7�is_logging_namez2LoggingChecker.visit_call.<locals>.is_logging_name�sH����4�9�e�o�6�6�?��t�y�~�u�z�:�:�?��I�N�'�4�+>�>�
r9�tuple[bool, str | None]c�\��t�j��D]�}t|tj��ry|jj}t|tj��rS|�	��dks+td�|���D����rd|jjfcS��dS)N�logging.Loggerc3�FK�|]}|���dkV��dS)rtN)�qname)�.0�ancestors  r7�	<genexpr>zELoggingChecker.visit_call.<locals>.is_logger_class.<locals>.<genexpr>�sF������ (�%�N�N�,�,�0@�@������r9T)FN)
r
r)r1r2r3�_proxied�parentr�ClassDefrv�any�	ancestorsr6)�inferredr{r\s  �r7�is_logger_classz2LoggingChecker.visit_call.<locals>.is_logger_class�s����%�d�i�0�0�

<�

<���h��(;�<�<�	<�%�.�5�F�!�&�%�.�9�9�<������*:�:�:����,2�,<�,<�,>�,>������;� $�X�%6�%;�;�;�;�;���;r9N)r.r/)r.rr)r)�attrname�_check_log_method)rWr\rqr�r6�results``    r7�
visit_callzLoggingChecker.visit_call�s�����	�	�	�	�	�	�	�	�	�	�	�	�	��?���	��9�%�D�D�*�?�,�,�L�F�D��
������t�T�*�*�*�*�*r9r6�strc���|dkr+|js|jst|j��dkrdSd}n%|tvr|js|js|jsdSd}ndS|j|}t|tj��r�|}|jdk}|jdkrB��	|��s-t�fd�|j|jfD����}|dk}|r.��
d	|��|��f�
��dSdSt|tj��r��|��dSt|tj��r��||��dSt|tj��r?t)|��rdS��
d|��|��f�
��dSdS)z9Checks calls to logging.log(level, format, *format_args).�log�NrKr�%�+c3�j�K�|]-}��tj|�����)dV��.dS�rKN)�_is_operand_literal_strr	�
safe_infer)rw�operandrWs  �r7ryz3LoggingChecker._check_log_method.<locals>.<genexpr>�sV�����.�.���3�3�E�4D�W�4M�4M�N�N�.��.�.�.�.�.�.r9r�r\�argsr)�starargs�kwargsrVr��CHECKED_CONVENIENCE_FUNCTIONSr1r�BinOp�op�#_is_node_explicit_str_concatenation�sum�left�right�add_message�_helper_string�Call�_check_call_func�Const�_check_format_string�	JoinedStr�str_formatting_in_f_string)rWr\r6�
format_pos�
format_arg�binop�emit�total_number_of_stringss`       r7r�z LoggingChecker._check_log_method�s:����5�=�=��}�
���
�s�4�9�~�~��/A�/A���()�J�J�
�2�
2�
2��}�
���
�4�9�
����J�J��F��Y�z�*�
��j�%�+�.�.�	��E��8�s�?�D��x�3���t�'O�'O�PU�'V�'V��*-�.�.�.�.�$)�J���#<�.�.�.�+�+�'�
/��2���
�� � �&���-�-�d�3�3�5�!������
�
��
�E�J�
/�
/�	��!�!�*�-�-�-�-�-�
�
�E�K�
0�
0�		��%�%�d�J�7�7�7�7�7�
�
�E�O�
4�
4�	�)�*�5�5�
������/���)�)�$�/�/�1�
�
�
�
�
�
�	�	r9c�p�dg}|j�d|j��s|�d��|j�d|j��s|�d��|j�d|j��s|�d��d�|��S)	zGCreate a string that lists the valid types of formatting for this node.zlazy %zlogging-fstring-formatting�fstringrz	.format()rr�z or )rN�is_message_enabled�
fromlineno�append�join)rWr\�valid_typess   r7r�zLoggingChecker._helper_strings����j���{�-�-�(�$�/�
�
�	*�
���y�)�)�)��{�-�-�*�D�O�
�
�	,�
���{�+�+�+��{�-�-�.@�$�/�R�R�	$����s�#�#�#��{�{�;�'�'�'r9r��InferenceResult | Noner/c�L�t|tj��o
|jdkS)z;Return True if the operand in argument is a literal string.r�)r1rr�r6)r�s r7r�z&LoggingChecker._is_operand_literal_str$s"���'�5�;�/�/�I�G�L�E�4I�Ir9�nodes.NodeNGc�2�t|tj��sdSt�|j��pt�|j��o=t�|j��pt�|j��S)zEReturn True if the node represents an explicitly concatenated string.F)r1rr�r;r�r�r�r��r\s r7r�z2LoggingChecker._is_node_explicit_str_concatenation)s����$���,�,�	��5��2�2�4�9�=�=�
M��A�A�$�)�L�L�
�
�2�2�4�:�>�>�
N��A�A�$�*�M�M�	
r9c�"�tj|j��}d}d}t|tj��rSt
|||��rDt|j��s2|�	d||�
|��f���dSdSdSdS)z8Checks that function call is not format_string.format().)r��unicode)�formatrr�N)r	r�r)r1r2r3r8�is_complex_format_strr4r�r�)rWr\r)r+r-s     r7r�zLoggingChecker._check_call_func6s������	�*�*��"�����t�W�0�1�1�		��t�U�G�4�4�		�*�$�*�5�5�		�

���.���)�)�$�/�/�1�
�
�
�
�
�
�		�		�		�		�		�		r9r��
Literal[0, 1]c	�H�t|j|dzd���}|sdS|j|j}d}t|t��r|���}t|t��r�	|jdkrtj	|��\}}}}|rdSnD|jdkr9tj
|��\}}	}
td�|D����}||	z|
z}n#tj$rE}||j
}
|�d||
t|
��|j
f���Yd}~dSd}~wtj$r|�d	|�
��YdSwxYw||kr|�d|�
��dS||kr|�d|�
��dSdS)
z�Checks that format string tokens match the supplied arguments.

        Args:
          node: AST node to be checked.
          format_arg: Index of the format string in the node arguments.
        rKNrrBrDc�B�h|]\}}t|t���|��Sr()r1�int)rw�krFs   r7�	<setcomp>z6LoggingChecker._check_format_string.<locals>.<setcomp>is+��S�S�S�t�q�!�
�1�c�@R�@R�S��S�S�Sr9rr�rr�rr)�_count_supplied_tokensr��valuer1�bytes�decoder�rRr	�parse_format_string�parse_format_method_stringrV�UnsupportedFormatCharacter�indexr��ord�IncompleteFormatString)rWr\r��num_args�
format_string�required_num_args�keyword_argsrF�keyword_arguments�implicit_pos_args�explicit_pos_args�keyword_args_cnt�ex�chars              r7r�z#LoggingChecker._check_format_stringFs8��*�$�)�J��N�4D�4D�*E�F�F���	�
�F��	�*�-�3�
����m�U�+�+�	3�)�0�0�2�2�M��m�S�)�)�!	� 
��%��.�.�<A�<U�%�=�=�9�L�"3�Q��$������'�5�0�0�
�8��G�G�	�)�)�)�(+�S�S�'8�S�S�S�(�(�$�)�+<�<�?P�P�&����3�
�
�
�$�R�X�.��� � �0����D�	�	�2�8�4�!����
�����������/�
�
�
�� � �!;�$� �G�G�G����
�����'�'�'����4�4��@�@�@�@�@�
�)�
)�
)����3�$��?�?�?�?�?�*�
)s%�7&C%�AC%�%E!�4:D4�4)E!� E!N)rFrGr.rH)r\r]r.rH)r\rgr.rH)r\rjr.rH)r\rjr6r�r.rH)r\rjr.r�)r�r�r.r/�r\r�r.r/)r\rjr�r�r.rH)�__name__�
__module__�__qualname__�__doc__r6r�msgs�optionsr[rfrir�r�r��staticmethodr�r�r�r�r(r9r7r;r;�sd������+�+��D��D�
�'��3�F�	
�
�		
�
#� � �1�!�5�>�P�
�
�
	
��G�08�8�8�8�"����;�;�;�;�+�+�+�+�@-�-�-�-�^(�(�(�(�"�J�J�J��\�J��

�

�

��\�

����� 6@�6@�6@�6@�6@�6@r9r;r\r�c�b�tj|��}|�4t|tj��rt|jt��sdS	ttj	���
|j����}n#t$rYdSwxYwtd�|D����S)zJReturn whether the node represents a string with complex formatting specs.NTFc3�$K�|]\}}}}|V��dSrmr()rwrF�format_specs   r7ryz(is_complex_format_str.<locals>.<genexpr>�s+����@�@�5��1�k�1�{�@�@�@�@�@�@r9)
r	r�r1rr�r�r��list�string�	Formatter�parse�
ValueErrorr})r\r�parseds   r7r�r�s������%�%�H����8�U�[�)�)��.8����.M�.M���t���f�&�(�(�.�.�x�~�>�>�?�?���������u�u������@�@��@�@�@�@�@�@s�8B�
B�Br��list[nodes.NodeNG]r�c�4�td�|D����S)apCounts the number of tokens in an args list.

    The Python log functions allow for special keyword arguments: func,
    exc_info and extra. To handle these cases correctly, we only count
    arguments that aren't keywords.

    Args:
      args: AST nodes that are arguments for a log format string.

    Returns:
      Number of AST nodes that aren't keywords.
    c3�NK�|] }t|tj���dV��!dSr�)r1r�Keyword)rw�args  r7ryz)_count_supplied_tokens.<locals>.<genexpr>�s3����G�G�S�
�3��
�(F�(F�G�q�G�G�G�G�G�Gr9)r�)r�s r7r�r��s!���G�G�D�G�G�G�G�G�Gr9�nodes.JoinedStrc�>�td�|jD����S)znDetermine whether the node represents an f-string with string formatting.

    For example: `f'Hello %s'`
    c3��K�|]G�t�tj���d�jvot	�fd�t
D����V��HdS)r�c3�*�K�|]
}|�jvV��dSrm)r�)rw�x�vals  �r7ryz7str_formatting_in_f_string.<locals>.<genexpr>.<genexpr>�s)����� P� P�A��c�i�� P� P� P� P� P� Pr9N)r1rr�r�r}�MOST_COMMON_FORMATTING)rwr�s @r7ryz-str_formatting_in_f_string.<locals>.<genexpr>�ss���������c�5�;�'�'���s�y��P�S� P� P� P� P�9O� P� P� P�P�P������r9)r}�valuesr�s r7r�r��s4������;������r9rNrrHc�J�|�t|����dSrm)�register_checkerr;)rNs r7�registerr��s$��
���N�6�2�2�3�3�3�3�3r9)r(r()r)r*r+r,r-r,r.r/r�)r�r�r.r�)r\r�r.r/)rNrr.rH)%r��
__future__rr��sys�typingrr2rr�astroid.typingr�pylintr�pylint.checkersr	�pylint.checkers.utilsr
�
pylint.typingr�version_infor�typing_extensions�pylint.lintrr�__annotations__r��	frozensetr�r8�BaseCheckerr;r�r�r�r�r(r9r7�<module>rsG��
)�(�(�"�"�"�"�"�"�
�
�
�
�
�
�
�
� � � � � � ����� � � � � � � � �*�*�*�*�*�*�������!�!�!�!�!�!�+�+�+�+�+�+�0�0�0�0�0�0���v����������)�)�)�)�)�)��%�$�$�$�$�$�$�
������
�s>�>��@�@�@�@�F	!�	!�	!��#��#;�#;�#;�<�<��VX������,w@�w@�w@�w@�w@�X�)�w@�w@�w@�tA�A�A�A�
H�
H�
H�
H� 
�
�
�
�4�4�4�4�4�4r9

Hacked By AnonymousFox1.0, Coded By AnonymousFox