
    cM
                    t    d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	m
Z
mZ dZdd	ZddZdddZddZddZdS )z)Different utilities for the numpy brains.    )annotations)extract_node)InferenceContext)	AttributeImportNameNodeNG)1200returnboolc                 8    t                      } | o
| t          k    S )z*Returns True if numpy supports type hints.)_get_numpy_version NUMPY_VERSION_TYPE_HINTS_SUPPORT)np_vers    ?lib/python3.11/site-packages/astroid/brain/brain_numpy_utils.pynumpy_supports_type_hintsr      s    !!F?f???    tuple[str, str, str]c                     	 ddl } t          | j        j                            d                    S # t          t
          f$ r Y dS w xY w)zj
    Return the numpy version number if numpy can be imported.

    Otherwise returns ('0', '0', '0')
    r   N.)r   r   r   )numpytupleversionsplitImportErrorAttributeError)r   s    r   r   r      sX    U]*0055666(   s   /2 AANcontextInferenceContext | Nonec                L    t          |           }|                    |          S )N)r   )r   infer)srcnoder   s      r   infer_numpy_memberr%   %   s#    D::g:&&&r   r$   r   c                    | j         d |                               d         D             }t          fd|D                       S )a>  
    Returns True if the node is a representation of a numpy module.

    For example in :
        import numpy as np
        x = np.linspace(1, 2)
    The node <Name.np> is a representation of the numpy module.

    :param node: node to test
    :return: True if the node is a representation of the numpy module.
    c                <    g | ]}t          |t                    |S  )
isinstancer   ).0xs     r   
<listcomp>z&_is_a_numpy_module.<locals>.<listcomp>7   s7       jF6K6K	  r      c              3  @   K   | ]}d f|j         v pd|j         v V  dS )r   )r   NN)names)r*   targetmodule_nicknames     r   	<genexpr>z%_is_a_numpy_module.<locals>.<genexpr>:   sO         
/"fl2Uo6U     r   )namelookupany)r$   potential_import_targetr1   s     @r   _is_a_numpy_moduler7   *   sv     iO ;;//2       -     r   member_namestrr	   c                B   t          |t                    r;|j        | k    r0t          |j        t                    rt          |j                  rdS t          |t                    r9|j        | k    r.|                                j                            d          rdS dS )z
    Returns True if the node is a member of numpy whose
    name is member_name.

    :param member_name: name of the member
    :param node: node to test
    :return: True if the node is a member of numpy
    Tr   F)	r)   r   attrnameexprr   r7   r3   root
startswith)r8   r$   s     r   looks_like_numpy_memberr?   @   s     	4##M[( ty$'' ty))	 t4I$ IIKK''00
 t5r   )r   r   )r   r   )N)r   r    )r$   r   r   r   )r8   r9   r$   r	   r   r   )__doc__
__future__r   astroid.builderr   astroid.contextr   astroid.nodes.node_classesr   r   r   r	   r   r   r   r%   r7   r?   r(   r   r   <module>rE      s   
 0 / " " " " " " ( ( ( ( ( ( , , , , , , F F F F F F F F F F F F $4  @ @ @ @   ' ' ' ' '
   ,     r   