관리-도구
편집 파일: json_response.cpython-311.pyc
� �܋f� � �` � d Z ddlZddlmZmZ ddlmZ ddlmZ G d� dej � � Z dS )z/ Various suggestions about JSON http responses � N)�checkers� interfaces)�utils)�BASE_IDc � � e Zd ZdZej fZdZde� d�dde� d�dde� d�d iZ e j d dd� � d � � � ZdS )�JsonResponseCheckerz` Looks for some common patterns when returning http responses containing JSON data! zjson-response-checker�R�01)z@Instead of HttpResponse(json.dumps(data)) use JsonResponse(data)�http-response-with-json-dumpsz@Used when json.dumps() is used as an argument to HttpResponse().�02)zKInstead of HttpResponse(content_type='application/json') use JsonResponse()�$http-response-with-content-type-jsonz7Used when HttpResponse() is returning application/json.�03)z3Redundant content_type parameter for JsonResponse()�(redundant-content-type-for-json-responsez�Used when JsonResponse() contains content_type parameter. This is either redundant or the content_type is not JSON which is probably an error.r r r c �F � |j � � � � d� � rk|j rdt |j d t j � � r?|j d j � � � dk r| � d|�� � |j � � � � d� � rw|j rp|j D ]h}|j dk r[|j � � � � � � � d� � dk r| � d |�� � n�i|j � � � � d � � r6|j r1|j D ]+}|j dk r| � d|�� � d S �(d S d S d S )N�HttpResponser z json.dumpsr )�node�content_typezapplication/json���r �JsonResponser ) �func� as_string�endswith�args� isinstance�astroid�Call�add_message�keywords�arg�value�lower�find)�selfr �keywords �u/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/pylint_django/checkers/json_response.py� visit_callzJsonResponseChecker.visit_call. s� � � �I���!�!�*�*�>�:�:� I�� � I� �4�9�Q�<���6�6� I� � �!��!�+�+�-�-��=�=����<�4��H�H�H��9��� � �)�)�.�9�9� �d�m� ��=� � ���;�.�0�0�W�]�5L�5L�5N�5N�5T�5T�5V�5V�5[�5[�\n�5o�5o�rt�5t�5t��$�$�%K�RV�$�W�W�W��E���9��� � �)�)�.�9�9� �d�m� ��=� � ���;�.�0�0��$�$�%O�VZ�$�[�[�[��E�E� 1� � � � � � � N) �__name__� __module__�__qualname__�__doc__r �IAstroidChecker�__implements__�namer �msgsr �check_messagesr&