
    9 f              	           d Z ddlmZ ddlmZmZmZmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZmZ de d	d
de d	dde ddde ddiZd Zd Zd Z G d de	          ZdS )zModels.    )Const)Assign
AssignNameClassDefFunctionDef)BaseChecker)BASE_ID)check_messages)PY3node_is_subclassE01)z,__unicode__ on a model must be callable (%s)zmodel-unicode-not-callablez3Django models require a callable __unicode__ methodW)z#No __unicode__ method on model (%s)model-missing-unicodezMDjango models should implement a __unicode__ method for string representation02)z=Found __unicode__ method on model (%s). Python3 uses __str__.zmodel-has-unicodezdDjango models should not implement a __unicode__ method for string representation when using Python303)z1Model does not explicitly define __unicode__ (%s)zmodel-no-explicit-unicodezDjango models should implement a __unicode__ method for string representation. A parent class of this model does, but ideally all models should be explicit.c                 "   t          | t                    ry| j        dk    rn|                                 D ]Y}t          |t                    s|j        d         j        dk    s/t          |j        t                    sJ|j        j        r dS ZdS )NMetar   abstractTF)
isinstancer   nameget_childrenr   targetsvaluer   )node
meta_childs     S/var/www/equiseq/venv/lib/python3.11/site-packages/pylint_django/checkers/models.py_is_meta_with_abstractr   #   s    $!! di6&9&9++-- 	 	Jj&11 %a(-;;j.66  % tt 5    c                 f    | j         dS | j         j        D ]}t          |dd           dk    r dS dS )NFr   python_2_unicode_compatibleT)
decoratorsnodesgetattr)r   	decorators     r   *_has_python_2_unicode_compatible_decoratorr&   5   sO    u_*  	9fd++/LLL44 M 5r   c                 b    | j         dk    rdS | j         dk    rt          | j                  rdS dS )N__unicode__T__str__F)r   r&   parent)methods    r   ,_is_unicode_or_str_in_python_2_compatibilityr,   @   s;    {m##t{i$Nv}$]$]t5r   c                   B    e Zd ZdZdZeZ ed          d             ZdS )ModelCheckerzDjango model checker.zdjango-model-checkerr   c                    t          |dd          sdS |                                D ]-}t          |          r dS t          |t                    rt          |                                          }t          |d         t                    sg|d         j        }|dk    r{|d         }|                                d         }|	                                r dS | 
                    dt           d|j        |	            dS t          |t                    r;|j        dk    r0t          r&| 
                    d
t           d|j        |	            dS /|                                D ]E}|j        |k    r8t!          |          r)| 
                    d
t           d|j        |	            dS Ft#          |          rdS t          rdS | 
                    d
t           d|j        |	           dS )zClass visitor.zdjango.db.models.base.Modelz.ModelNr   r(      r   r   )argsr   r   r   r   )r   r   r   r   r   listr   r   inferredcallableadd_messager	   r   r   methodsr*   r,   r&   )selfr   childgrandchildrenr   
grandchildassignedr+   s           r   visit_classdefzModelChecker.visit_classdefP   s     &CXNN 	F&&(( 	 	E%e,, %((  $U%7%7%9%9 : :!-"2J?? $Q',=((*1-
%..003$$&& FF  Wtyt LLL%-- %*2M2M Q$$____494$PPP
 llnn 	 	F}$$)UV\)])]$   Wtyt LLL 6d;; 	F 	FWtytDDDDDr   N)	__name__
__module____qualname____doc__r   MESSAGESmsgsr
   r<    r   r   r.   r.   J   sN        !DD^+,,4E 4E -,4E 4E 4Er   r.   N)r@   astroidr   astroid.nodesr   r   r   r   pylint.checkersr   pylint_django.__pkginfo__r	   pylint_django.compatr
   pylint_django.utilsr   r   rA   r   r&   r,   r.   rC   r   r   <module>rJ      sH          C C C C C C C C C C C C ' ' ' ' ' ' - - - - - - / / / / / / 5 5 5 5 5 5 5 5 OOO 
 OOO 
 OOO 
 OOO !2  $    ;E ;E ;E ;E ;E; ;E ;E ;E ;E ;Er   