
    ,h                    |    d Z ddlmZ ddlZddlZddlZddlmZ  G d dej                        Z	d
dZ
ddZddd	Zy)z4Utilities related to attribute docstring extraction.    )annotationsN)Anyc                  <     e Zd Zd fdZd fdZddZddZ xZS )	DocstringVisitorc                L    t         |           d | _        i | _        d | _        y N)super__init__targetattrsprevious_node_type)self	__class__s    e/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/pydantic/_internal/_docs_extraction.pyr
   zDocstringVisitor.__init__   s$    "&%'
8<    c                F    t         |   |      }t        |      | _        |S r   )r	   visittyper   )r   nodenode_resultr   s      r   r   zDocstringVisitor.visit   s#    gmD)"&t*r   c                    t        |j                  t        j                        r|j                  j                  | _        y y r   )
isinstancer   astNameid)r   r   s     r   visit_AnnAssignz DocstringVisitor.visit_AnnAssign   s(    dkk388,++..DK -r   c                |   t        |j                  t        j                        rt        |j                  j                  t              rs| j
                  t        j                  u rVt        j                  |j                  j                        }| j                  r|| j                  | j                  <   d | _	        y y y y r   )r   valuer   Constantstrr   	AnnAssigninspectcleandocr   r   )r   r   	docstrings      r   
visit_ExprzDocstringVisitor.visit_Expr   s    tzz3<<04::++S1''3==8(()9)9:I{{*3

4;;'DK 9 2 1r   )returnNone)r   zast.ASTr&   r   )r   zast.AnnAssignr&   r   )r   zast.Exprr&   r   )__name__
__module____qualname__r
   r   r   r%   __classcell__)r   s   @r   r   r      s    =
)	r   r   c                z    t        j                  dj                  |             }|j                  d      rd| }|S )N ) 	zdef dedent_workaround():
)textwrapdedentjoin
startswith)sourcededent_sources     r   _dedent_source_linesr6   (   s:    OOBGGFO4M, 5]ODr   c                   t        j                         }|rt        j                  |      t        j                  |       u r|j                  }	 t        j                  |      \  }}t        j
                  ||dz
  d        }t        |      }	 t        j                  |      }|j                  d   }t        |t        j                        r|j                  dk(  r|j                  d   }t        |t        j                        r|j                  | j                  k(  r|S |j"                  }|ry y # t        $ r Y w xY w# t         $ r Y ,w xY w)N   r   dedent_workaround)r"   currentframe	getmodulef_lineno
findsourcegetblockr6   r   parsebodyr   FunctionDefnameClassDefr(   SyntaxErrorOSErrorf_back)	clsframelnumlines_block_linesr5   
block_treestmts	            r   _extract_source_from_framerO   3   s     "E
U#w'8'8'==>>D+"--e4q &..uTAXZ/@A 4[ A
+!$=!9J &??1-D!$8TYYJ]=]#yy|!$5$))s||:S**1  #    s$   E  D1 1	D=<D= 	EEc                   |r	 t        j                  |       \  }}nt        |       }|si S t	        |      }t               }|j                  t        j                  |             |j                  S # t        $ r i cY S w xY w)aX  Map model attributes and their corresponding docstring.

    Args:
        cls: The class of the Pydantic model to inspect.
        use_inspect: Whether to skip usage of frames to find the object and use
            the `inspect` module instead.

    Returns:
        A mapping containing attribute names and their corresponding docstring.
    )
r"   getsourcelinesrE   rO   r6   r   r   r   r?   r   )rG   use_inspectr4   rK   r5   visitors         r   extract_docstrings_from_clsrT   Q   s{     	..s3IFA ,C0	(0M GMM#))M*+==  	I	s   A1 1A?>A?)r4   z	list[str]r&   r    )rG   	type[Any]r&   zlist[str] | None)F)rG   rU   rR   boolr&   zdict[str, str])__doc__
__future__r   r   r"   r0   typingr   NodeVisitorr   r6   rO   rT    r   r   <module>r\      s6    : " 
   s :<r   