
    zi>                       U d Z ddlmZ ddlZddlZddlZddlZddlmZ ddlm	Z	m
Z
 ddlmZ ddlmZmZmZmZmZ ddlZddlmZ dd	lmZ dd
lmZmZ ddlmZmZmZmZmZm Z  ddl!m"Z" ddl#m$Z$m%Z% ddl&m'Z' ddl(m)Z)m*Z*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1 erddl2m3Z3 ee4eeee4ef                  ee4         f         f         Z5ddhdhdhdhdhh ddhh dh dh dd
Z6dpd-Z7dqd2Z8drd6Z9dsdtd9Z:dud=Z;dvdBZ<i dCdDdEdFdGdHgifdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfZ=dge>dh<   diZ?djZ@diZA G dk dlee          ZBdwdoZCdS )xz!Imports checkers for Python code.    )annotationsN)defaultdict)	ItemsViewSequence)cached_property)TYPE_CHECKINGAnyDictListUnion)nodes)
ImportNode)BaseCheckerDeprecatedMixin)get_import_namein_type_checking_blockis_from_fallback_blockis_module_ignoredis_sys_guardnode_ignores_exception)EmptyReportError)
DotBackend
get_cycles)HIGH)	ParagraphSectionVerbatimText)MessageDefinitionTuple)IsortDriver)LinterStats)PyLinterztkinter.tixfpectloptparsezxml.etree.cElementTreeimp	formatter>   smtpdasynchatasyncoremacpath>   binhexparsersymbollib2to3>   	typing.io	typing.re	distutils>   uucginisaifcspwdcgitbchunkcryptpipessunauimghdrmsilibsndhdrxdrlibaudioopmailcapnntplib	sre_parse	telnetlibossaudiodevsre_compilesre_constants)
)r   r   r   )      r   )rG   rG   r   )rG      r   )rG      r   )rG      r   )rG      r   )rG   	   r   )rG   
   r   )rG      r   noder   contextnodes.LocalsDictNodeNGnamestrbase
str | Nonelevel
int | Nonealiasreturn9tuple[nodes.Import | nodes.ImportFrom | None, str | None]c                   |r| d| n|d}d}d}|j         D ]}|| u r|                                |                                 u r|j        | j        k    rAt          |t          j                  rDt          fd|j        D                       rd} n|j        D ]\  }	}
|
s|	|k    rd}d} n|r not          |t          j                  rR||j	        k    rG|j        D ];\  }	}
|j
         d|	 k    rd} n#|dk    r||	k    r|s|
sd} n|
s|	|k    rd}d} n<|r n|rt          j        ||           s||fS d	S )
zEReturn the node where [base.]<name> is imported or None if not found..NF
reimportedc              3  0   K   | ]}|d          k    V  dS )r   N ).0inamefullnames     b/var/www/tmov.alphamb/tmov_inventario/venv/lib/python3.11/site-packages/pylint/checkers/imports.py	<genexpr>z$_get_first_import.<locals>.<genexpr>i   s,      AAE8uQx'AAAAAA    Tshadowed-import*NN)bodyscope
fromlineno
isinstancer   Importanynames
ImportFromrW   modnameastroidare_exclusive)rP   rQ   rS   rU   rW   rY   firstfoundmsgimported_nameimported_aliasrc   s              @rd   _get_first_importrz   T   s    $(1$THEE
C " "D==;;==DJJLL((U-=-O-OeU\** 	AAAAU[AAAAA 16  -~% -5*@*@ E+CE u/00 	##5:[  1M>em#E#Em#E#EEE $ M11!& 2*8 2 !%) mu.D.D $/ E W*5$77 cz:rf   rr   ignored_modulesSequence[str]boolc                    t          ||          rdS t          |           rdS t          | j        t          j                  rt          | j                  rdS t          | t                    S )NT)	r   r   rm   parentr   Ifr   r   ImportError)rP   rr   r{   s      rd   _ignore_import_failurer      sn    
 /22 t d## t$+ux(( \$+-F-F t!$444rf   mod_files_listItemsView[str, set[str]]_ImportTreec                8   i }| D ]\  }}|g g}|                     d          D ]=}t          |d         t                    sJ |d                             |i g f          }>t          |d         t                    sJ |d                             |           |S )zGet a list of 2-uple (module, list_of_files_which_import_this_module),
    it will return a dictionary to represent this as a tree.
    r]   r      )splitrm   dict
setdefaultlistextend)r   	tree_defsmodfilesrP   prefixs         rd   _make_tree_defsr      s      I$  
U/8"oiinn 	8 	8Fd1gt,,,,,7%%fr2h77DD$q'4(((((Qurf   data
indent_strc                0   g }|                                  }t          t          |d                     D ]\  }\  }\  }}|sdn%dd                    t          |                     d}||                    | d|            d	}	n>|                    | d
| d|            |t          |          dz
  k    r| d	}	n| d}	|r8t          |t                    r#|                    t          ||	                     d                    |          S )z3Return a string which represents imports as a tree.c                    | d         S )Nr   r`   )xs    rd   <lambda>z!_repr_tree_defs.<locals>.<lambda>   s    aPQd rf   )key (,)N z  z\-r   z| 
)	items	enumeratesortedjoinappendlenrm   r   _repr_tree_defs)
r   r   linesnodes_itemsir   subr   
files_listsub_indent_strs
             rd   r   r      sG   E**,,K"+F;NN,S,S,S"T"T ? ?C#u$HRR*Hchhve}}.E.E*H*H*H
LLC..*..///!NNLLZ==3====>>>C$$q((($.!2!2!2$.!2!2!2 	?:c4(( 	?LLn==>>>99Urf   filenamedep_infodict[str, set[str]]c                   i }t          t          j                            t          j                            |                     d         d          }|                    d           t          |                                          D ]Q\  }}t          |          }d||<   |                    |           |D ] }||vrd||<   |                    |           !Rt          |                                          D ]-\  }}t          |          D ]}|	                    ||           .|
                    |           S ),Write dependencies as a dot (graphviz) file.r   LR)rankdirzURL="." node[shape="box"]r   )r   ospathsplitextbasenameemitr   r   	emit_node	emit_edgegenerate)r   r   doneprinterrr   dependenciessorted_dependencies
depmodnames           rd   _dependencies_graphr      sR   D))"'*:*:8*D*DEEaHRVWWWGLL,---!'(8(8!9!9 . .$\22W'"""- 	. 	.J%%#$Z !!*---	. %+8>>+;+;$<$< 3 3 
Ll++ 	3 	3Ggz2222	3H%%%rf   sectr   gtypeNonec                v    t          | |          }|                    t          | d| f                     dS )zaGenerate a dependencies graph and add some information about it in the
    report's section.
    z"imports graph has been written to N)r   r   r   )r   r   r   r   
outputfiles        rd   _make_graphr      sD     %Xx88JKK	eSSzSSUVVWWWWWrf   E0401zUnable to import %simport-errorz4Used when pylint has been unable to import a module.	old_names)F0401zold-import-errorE0402)z2Attempted relative import beyond top-level packagerelative-beyond-top-levelzSUsed when a relative import tries to access too many levels in the current package.R0401)zCyclic import (%s)cyclic-importzBUsed when a cyclic import between two or more modules is detected.R0402)zUse 'from %s import %s' insteadconsider-using-from-importzEmitted when a submodule of a package is imported and aliased with the same name, e.g., instead of ``import concurrent.futures as futures`` use ``from concurrent import futures``.W0401)zWildcard import %swildcard-importz-Used when `from module import *` is detected.W0404)zReimport %r (imported line %s)r^   z.Used when a module is imported more than once.W0406)zModule import itselfimport-selfz'Used when a module is importing itself.W0407)z!Prefer importing %r instead of %rpreferred-modulez?Used when a module imported has a preferred replacement module.W0410)z:__future__ import is not the first non docstring statementmisplaced-futurezgPython 2.5 and greater require __future__ import to be the first non docstring statement in the module.C0410)z!Multiple imports on one line (%s)multiple-importszBUsed when import statement importing multiple modules is detected.C0411)z%s should be placed before %swrong-import-orderzvUsed when PEP8 import order is not respected (standard imports first, then third-party libraries, then local imports).C0412)z'Imports from package %s are not groupedungrouped-importsz.Used when imports are not grouped by packages.C0413)z5Import "%s" should be placed at the top of the modulewrong-import-positionz%Used when code and imports are mixed.C0414)z-Import alias does not rename original packageuseless-import-aliaszwUsed when an import alias is same as original package, e.g., using import numpy as numpy instead of import numpy as np.C0415)zImport outside toplevel (%s)import-outside-toplevelzwUsed when an import statement is used anywhere other than the module toplevel. Move this import to the top of the file.W0416)zShadowed %r (imported line %s)rg   zFUsed when a module is aliased with a name that shadows another import.z!dict[str, MessageDefinitionTuple]MSGSr`   )enchantc                  2   e Zd ZdZdZi ej        eZdZ	de	ddddfd	e
dd
ddfddddddfddddddfddddddfdeddddfdeddddfddddddfddddddfd dddd!dff
Zdjd&Zdkd'Zdld)Zdkd*Zdmd,Zdnd/Zdod1Zdpd4Zdqd6Zdrd8Zdpd9Zdsd;ZexZxZxZxZxZxZZ dtd=Z!e!xZ"xZ#Z$drd>Z%drd?Z&dudAZ'dvdDZ(e)dwdG            Z*dxdJZ+dydNZ,dzdPZ-d{dRZ.dudSZ/	 	 d|d}dYZ0d~d`Z1d~daZ2ddcZ3e4dldd            Z5e4dlde            Z6ddgZ7ddhZ8dudiZ9dTS )ImportsCheckerzBaseChecker for import statements.

    Checks for
    * external modules dependencies
    * relative / wildcard imports
    * cyclic imports
    * uses of deprecated modules
    * uses of modules instead of preferred modules
    importsr`   zdeprecated-modulescsvz	<modules>zBDeprecated modules which should not be used, separated by a comma.)defaulttypemetavarhelpzpreferred-modulesz<module:preferred-module>z?Couples of modules and preferred modules, separated by a comma.zimport-graphr   r   z	<file.gv>zOutput a graph (.gv or any supported image format) of all (i.e. internal and external) dependencies to the given file (report RP0402 must not be disabled).zext-import-graphzOutput a graph (.gv or any supported image format) of external dependencies to the given file (report RP0402 must not be disabled).zint-import-graphzOutput a graph (.gv or any supported image format) of internal dependencies to the given file (report RP0402 must not be disabled).zknown-standard-libraryzYForce import order to recognize a module as part of the standard compatibility libraries.zknown-third-partyzJForce import order to recognize a module as part of a third party library.zallow-any-import-levelzNList of modules that can be imported at any level, not just the top level one.zallow-wildcard-with-allFynz<y or n>z8Allow wildcard imports from modules that define __all__.zallow-reexport-from-packagez:Allow explicit reexports by alias from a package __init__.linterr!   rZ   r   c                   t          j        | |           t          t                    | _        g | _        d | _        i | _        t                      | _        dd| j	        fdd| j
        ff| _        t          t                    | _        d S )NRP0401zExternal dependenciesRP0402zModules dependencies graph)r   __init__r   setimport_graph_imports_stack_first_non_import_node_module_pkg_allow_any_import_level_report_external_dependencies_report_dependencies_graphreports_excluded_edges)selfr   s     rd   r   zImportsChecker.__init__  s    T6***8CC8H8H<>&*#  	 25$.0RS3T5TU
 <Gs;K;Krf   c                   i | j         j        _        | j         j        | j         _        t          t                    | _        i | _        d| _        | j         j        j	        | _
        t          d | j         j        j        D                       | _        t	          | j         j        j                  | _        | j         j        j        | _        dS )4Called before visiting project (i.e set of modules).Fc              3  H   K   | ]}d |v |                     d           V  dS ):Nr   )ra   modules     rd   re   z&ImportsChecker.open.<locals>.<genexpr>  s@       &
 &
f}} LL}}}&
 &
rf   N)r   statsr   r   r   r   r   _current_module_packageconfigr{   _ignored_modulesr   preferred_modulesallow_any_import_levelr   allow_reexport_from_package_allow_reexport_packager  s    rd   openzImportsChecker.open  s    )+& K-',,',$/3{/A/Q!% &
 &
+,>&
 &
 &
 "
 "

 (+4;+=+T'U'U$'+{'9'U$$$rf   defaultdict[str, set[str]]c                    t          j        | j                  }|D ](}||                             | j        |                    )|S N)copydeepcopyr   difference_updater   )r  filtered_graphrP   s      rd   #_import_graph_without_ignored_edgesz2ImportsChecker._import_graph_without_ignored_edges  sO    t'899" 	O 	OD4 2243G3MNNNNrf   c                    | j                             d          ra|                                 }t          |          }t	          ||          D ].}|                     dd                    |                     -dS dS )r  r   )verticesz -> )argsN)r   is_message_enabledr  r   r   add_messager   )r  graphr  cycles       rd   closezImportsChecker.close  s    ;))/:: 	K<<>>EE{{H#EH=== K K  v{{57I7I JJJJ		K 	KK Krf   =tuple[defaultdict[str, set[str]], defaultdict[str, set[str]]]c                    | j                             d          r| j        | j        fS t	          t
                    t	          t
                    fS Nr   )r   r  r   r   r   r   r  s    rd   get_map_datazImportsChecker.get_map_data  sH     ;))/:: 	=%t';<<C  +c"2"233rf   r   Clist[tuple[defaultdict[str, set[str]], defaultdict[str, set[str]]]]c                F   | j                             d          rt          t                    | _        t          t                    | _        |D ];}|\  }}| j                            |           | j                            |           <|                                  d S d S r$  )r   r  r   r   r   r   updater!  )r  r   r   	to_updater  excluded_edgess         rd   reduce_map_datazImportsChecker.reduce_map_data  s    
 ;))/:: 	 +C 0 0D#.s#3#3D ! < <	(1%~!((///$++N;;;;JJLLLLL	 	rf   set[str]c                    t          | j        j        j                  }t                                          D ]*\  }}|t          j        k    r|                    |          }+|S )z*Callback returning the deprecated modules.)	r   r   r
  deprecated_modulesDEPRECATED_MODULESr   sysversion_infounion)r  all_deprecated_modules
since_versmod_sets       rd   r.  z!ImportsChecker.deprecated_modules  se     "%T[%7%J!K!K#5#;#;#=#= 	O 	OJS---)?)E)Eg)N)N&%%rf   rP   nodes.Modulec                    |j         | _        dS )z<Store if current module is a package, i.e. an __init__ file.N)packager	  r  rP   s     rd   visit_modulezImportsChecker.visit_module  s    '+|$$$rf   nodes.Importc                   |                      |           |                     |           |                     |           d |j        D             }t	          |          dk    r+|                     dd                    |          |           |D ]}|                     ||           |                     ||           | 	                    ||          }t          |j        t          j                  r|                     |           t          |                                t          j                  r|                     ||           ||                     ||j                   dS )z+Triggered when an import statement is seen.c                    g | ]\  }}|S r`   r`   ra   rS   _s      rd   
<listcomp>z/ImportsChecker.visit_import.<locals>.<listcomp>  s    000'$000rf   rH   r   , r  rP   N)_check_reimport_check_import_as_rename_check_toplevelrp   r   r  r   check_deprecated_module_check_preferred_module_get_imported_modulerm   r   r   Module_check_positionrk   _record_import_add_imported_modulerS   )r  rP   rp   rS   imported_modules        rd   visit_importzImportsChecker.visit_import  si   T"""$$T***T"""00TZ000u::??/dii6F6FTRRR 	B 	BD((t444((t444"77dCCO$+u|44 +$$T***$**,,55 ;##D/:::&%%dO,@AAAA	B 	Brf   nodes.ImportFromc                X   |j         }|                     ||          }t          ||          }|                     |           |                     |           |                     ||           |                     ||           |                     ||           |                     |           | 	                    |||j
                   |                     |           t          |j        t          j                  r|                     |           t          |                                t          j                  r|                     ||           |dS |j        D ]G\  }}|dk    r!|                     ||j         d|            ,|                     ||j                   HdS )z(Triggered when a from statement is seen.)r   rW   Nrh   r]   )rr   rH  r   rD  _check_misplaced_futurerF  rG  _check_wildcard_imports_check_same_line_importsrC  rW   rE  rm   r   r   rI  rJ  rk   rK  rp   rL  rS   )r  rP   r   rM  absolute_namerS   r?  s          rd   visit_importfromzImportsChecker.visit_importfrom(  s   <33D(CC'h77$$T***$$T***$$T=999$$T8444$$T?;;;%%d+++THDJGGGT"""dk5<00 	'  &&&djjllEL11 	7o666"Fz 	F 	FGD!s{{))$?3G0P0P$0P0PQQQQ))$0DEEEE		F 	Frf   c                V   |                      |          \  }}}t                      }t                      }d }||z   |z   D ]\  }}	t          |t          j                  r|n|}
|	                    d          \  }}}|rd||k    r^||
v rZt          |          sKt          |j        t          j                  rt          |j                  s| 
                    d||           |}| j                            d|j                  s|
                    |           g | _        d | _        d S )Nr]   r   rP   r  )_check_imports_orderr   rm   r   rq   	partitionr   r   r   r   r  r   r  rl   addr   r   )r  rP   std_importsext_importsloc_imports
met_importmet_fromcurrent_packageimport_nodeimport_namemetr8  r?  s                rd   leave_modulezImportsChecker.leave_moduleD  sW   040I0I$0O0O-[+  #uu
 UU(3k(AK(O 	 	$K(e6FGGW((ZC'11#66MGQ
V#w..sNN.{;; # {158<< # %[%788	 #   !4;W UUU%O;11#[%;   GGG &*###rf   gnodes.If | nodes.Expr | nodes.Comprehension | nodes.IfExp | nodes.Assign | nodes.AssignAttr | nodes.Tryc                   | j         rd S t          |j        t          j                  sd S t          |t          j                  r:t          |                    t          j        t          j	        f                    rd S t          |t          j
                  r"d |j        D             }t          |          rd S || _         d S )Nc                    g | ]P}t          |t          j                  o3|j                            d           o|j                            d           QS )__)rm   r   
AssignNamerS   
startswithendswith)ra   targets     rd   r@  z@ImportsChecker.compute_first_non_import_node.<locals>.<listcomp>}  sg         65#344 /K**400/K((..  rf   )r   rm   r   r   rI  Tryro   nodes_of_classrn   rq   Assigntargetsall)r  rP   valid_targetss      rd   compute_first_non_import_nodez,ImportsChecker.compute_first_non_import_noded  s     & 	F$+u|44 	FdEI&& 	3u/? @AA,
 ,
 	 FdEL)) 
	  #l	  M =!! &*###rf   <nodes.FunctionDef | nodes.While | nodes.For | nodes.ClassDefc                   | j         rd S t          |j                                        t          j                  sd S |}t          |j        t          j                  s&|j        }t          |j        t          j                  &t          |t          j        t          j        f          r:t          |	                    t          j
        t          j        f                    rd S || _         d S r  )r   rm   r   rk   r   rI  r   rm  ro   rn  rn   rq   )r  rP   roots      rd   visit_functiondefz ImportsChecker.visit_functiondef  s     & 	F $+++--u|<< 	FT[%,77 	;D T[%,77 	 dUXuy122 	4&&e6F'GHHII &*###rf   c                    |j         }|dk    rT|                                }|r<t          |t          j                  r|j         dk    s|                     d|           d S d S )N
__future__r   rP   )rr   previous_siblingrm   r   rq   r  )r  rP   r   prevs       rd   rQ  z&ImportsChecker._check_misplaced_future  sz    <|##((**D D tU%566D;?<<;W;W$$%7d$CCCF $#rf   c                    d |j         D             }t          j        |          }|                                D ]*\  }}|dk    r|                     d|||j        f           +d S )Nc              3      K   | ]	\  }}|V  
d S r  r`   r>  s      rd   re   z:ImportsChecker._check_same_line_imports.<locals>.<genexpr>  s&      00'$000000rf   r   r^   rW  )rp   collectionsCounterr   r  rl   )r  rP   rp   counterrS   counts         rd   rS  z'ImportsChecker._check_same_line_imports  s|    00TZ000%e,,"==?? 	X 	XKD%qyy  Ddo?V WWW	X 	Xrf   r   c                    | j         rt| j                            d| j         j                  r,|                     d||                                           dS | j                            d|j        |           dS dS )zCheck `node` import or importfrom node position is correct.

        Send a message  if `node` comes before another instruction
        r   rW  N)r   r   r  rl   r  	as_stringadd_ignored_messager9  s     rd   rJ  zImportsChecker._check_position  s     & 
	{--')D)O  	   +$T^^=M=M !      //+T_d    
	 
	rf   importedmodnodenodes.Module | Nonec                L   t          |t          j                  r|j        }n|r|j        nd}|s,|j        d         d                             d          d         }t          |t          j                  r|j        pddk    rd|z   }| j        	                    ||f           dS )z'Record the package `node` imports from.Nr   r]   r   )
rm   r   rq   rr   rS   rp   r   rW   r   r   )r  rP   r  importednames       rd   rK  zImportsChecker._record_import  s     dE,-- 	M<LL3BL?//L 	::a=+11#66q9LdE,-- 	.4:?q2H2H -L""D,#788888rf   list[tuple[ImportNode, str]]r}   c                R     d |D             }t           fd|D                       S )Nc                    g | ]\  }}|S r`   r`   )ra   ra  r?  s      rd   r@  z6ImportsChecker._is_fallback_import.<locals>.<listcomp>  s    ???#3K;???rf   c              3  B   K   | ]}t          j        |          V  d S r  )rs   rt   )ra   ra  rP   s     rd   re   z5ImportsChecker._is_fallback_import.<locals>.<genexpr>  s0      WW7(d;;WWWWWWrf   )ro   )rP   r   s   ` rd   _is_fallback_importz"ImportsChecker._is_fallback_import  s<     @?w???WWWWwWWWWWWrf   _module_node_tuple[list[tuple[ImportNode, str]], list[tuple[ImportNode, str]], list[tuple[ImportNode, str]]]c           	        g }g }g }g }g }g }g }g }	t          | j        j                  }
| j        D ]$\  }}|                    d          rd|                    d          d         z   }n|                    d          d         }t          |j        t          j	                   }| j        
                    d|j                   }|
                    |          }||f}|dv r|                    |           |p|p|	}|                     ||          r|rT|sR|                     d|d|                                 dd|d         d                                          df           =|d	k    r|                    |           |                    |           |s9|s|                    |           n!| j                            d|j        |           |p|	}|rT|sR|                     d|d
|                                 dd|d         d                                          df           |dk    r|                    |           |                    |           |s9|s|                    |           n!| j                            d|j        |           |	}|rT|sR|                     d|d|                                 dd|d         d                                          df           |dk    rU|                    ||f           |s<|s|	                    ||f           | j                            d|j        |           &|||fS )zChecks imports of module `node` are grouped by category.

        Imports must follow this order: standard, 3rd party, local
        r]   r   r   r   >   FUTURESTDLIBzstandard import ""rW  
THIRDPARTYzthird party import "
FIRSTPARTYzfirst party import "LOCALFOLDER)r   r   r
  r   rj  r   rm   r   r   rI  r  rl   place_moduler   r  r  r  r  )r  r  r[  third_party_importsfirst_party_importsexternal_importslocal_importsthird_party_not_ignoredfirst_party_not_ignoredlocal_not_ignoredisort_driverrP   rr   r8  nestedignore_for_import_orderimport_categorynode_and_package_importwrong_imports                      rd   rX  z#ImportsChecker._check_imports_order  sI    57<><>9;68@B@B:<"4;#566!0 M	 M	MD'!!#&& 0c 2 21 55!--,,Q/#DK>>>F*.+*H*H$do+ + '# +77@@O'+Wo#"666""#:;;;+ ).)( 
 ++D,??   $$,!C0@0@CCCAQ 2 < < > >AAA %    !L00#**+BCCC ''(?@@@ 2 /667NOOOO770$/4    7K:K  $$,!F4>>3C3CFFFAQ 2 < < > >AAA %    !L00#**+BCCC ''(?@@@ 2 /667NOOOO770$/4    1  $$,!F4>>3C3CFFFAQ 2 < < > >AAA %    !M11$$dG_555 2 )00$AAAA770$/4   ,m;;rf   
importnoderr   rT   c                   	 |                     |          S # t          j        $ r4 t          ||| j                  rY d S |                     d|           Y nt          j        $ r;}d|d|j         d}|                     d|j        |t                     Y d }~nd }~wt          j
        $ r | j                            d          sY d S t          ||| j                  rY d S | j        j        j        st          |          rY d S t!          ||          }|                     dt#          |          |	           Y nt$          $ r}t          j        |d }~ww xY wd S )
Nr   rz  zCannot import z	 due to ''zsyntax-error)liner  
confidencer   rB  )do_import_modulers   TooManyLevelsErrorr   r  r  AstroidSyntaxErrorerrorlinenor   AstroidBuildingErrorr   r  r
  analyse_fallback_blocksr   r   repr	ExceptionAstroidError)r  r  rr   excmessagedotted_modnamees          rd   rH  z#ImportsChecker._get_imported_moduleU  s   	...w777) 	K 	K 	K%j'4;PQQ tt8zJJJJJ) 	 	 	GwGG39GGGGZ%6WQU          + 	Y 	Y 	Y;11.AA tt%j'4;PQQ ttK&>*:66 tt,ZAAN^$~2F2FZXXXXX 	. 	. 	.&A-	.tsD    %EEE'1B,EE% E5E?	EEEimportedmodnamec                   |                                 j        }|                                 j        }t          j                            t          j                            |                    d         }	 t          j        	                    ||          }n# t          $ r Y nw xY w||k    r|                     d|           d	S t          j                            |          s|dk    r-|| j        vr$|                    dd          d         | j        |<   | j        j        j        }|                    |t'                                }||vr|                    |           | j        |                             |           | j                            d|j                  rt1          |          r$| j        |                             |           d	S d	S d	S )
z8Notify an imported module, used to analyze dependencies.r   r   rz  r   r]   r   r   )r  N)rv  filerS   r   r   r   r   rs   modutilsget_module_partr   r  is_stdlib_moduler   rsplitr   r  r   r   r   rZ  r   r  r  r   r   )r  rP   r  module_filecontext_namerU   dependencies_statimportedmodnamess           rd   rL  z#ImportsChecker._add_imported_moduleu  s   iikk&yy{{'w 0 0 = =>>qA	%.>> OO  	 	 	D	 ?**]66666!22?CC 	Hz!!l$:J&J&J 2>1D1DS!1L1LQ1O . 6:[5F5S0;;OSUUSS#333 $$\222 l+//@@@;11dk 2   H'--H $\266GGGGG%	H 	HH Hs   6 B 
B$#B$mod_pathc                   |gt          t          j        j        j                  rfdj        D             fd| j        D             }|r3|                     d| j        |d                  |d         f           dS dS )z0Check if the module has a preferred replacement.c                4    g | ]}j          d |d          S r]   r   )rr   ra   rS   rP   s     rd   r@  z:ImportsChecker._check_preferred_module.<locals>.<listcomp>  s-    NNN4dl66T!W66NNNrf   c                d    g | ],}D ]'}||k    s||                     d           d         v %|(-S r  r  )ra   kr   mod_compares      rd   r@  z:ImportsChecker._check_preferred_module.<locals>.<listcomp>  s]     
 
 
"
 
 CxxCIIcNN1%%%  &%%%rf   r   r   rW  N)rm   rs   r   node_classesrq   rp   r  r  )r  rP   r  matchesr  s    `  @rd   rG  z&ImportsChecker._check_preferred_module  s      jdGM6ABB 	ONNNN4:NNNK
 
 
 
+
 
 
  	",WQZ8'!*E      	 	rf   c                   |j         }|D ]}t          |          s d S |d                             dd          }|d         }|d         }||k    rHt          |          dk    r0| j        du s	| j        du r|                     d|t                     t          |          d	k    r |                     d
||d         |f           d S )Nr   r]   r   )maxsplitFr   )rP   r  rH   r   rW  )rp   rq  r  r   r  r	  r  r   )r  rP   rp   rS   splitted_packagesrb  aliased_names          rd   rD  z&ImportsChecker._check_import_as_rename  s   
 	 	Dt99  $QsQ ? ?+B/K7Ll**$%%**,55/588  !7dt TTTT&''1,,  0+A.< !   !	 	rf   Nr   rV   rW   rX   c           
        | j                             d          s| j                             d          sdS |                                }|                                }||fg}||ur|                    |df           |D ]\\  }}|j        D ]O\  }	}
t          |||	|||
          \  }}|1|/|dk    r|	n|
}	|                     |||	|j        ft                     P]dS )zDCheck if a module with the same name is already imported or aliased.r^   rg   N)rP   r  r  )
r   r  framerv  r   rp   rz   r  rl   r   )r  rP   r   rW   r  rv  contextsknown_contextknown_levelrS   rY   ru   rw   s                rd   rC  zImportsChecker._check_reimport  s/    {--
 
 	+001BCC	 F

yy{{EN#uOOT4L)))*2 		 		&M;#z  e.-xe 
s $#&,#6#644ED$$$dE4D-ERV %   		 		rf   r   r   r?  r    _dummyLinterStats | Nonec                    t          | j                                                  }|st                      t	          |          }|                    t          |                     dS )z5Return a verbatim layout for displaying dependencies.N)r   _external_dependencies_infor   r   r   r   r   )r  r   r?  r  r   tree_strs         rd   r   z,ImportsChecker._report_external_dependencies  sa     #4#C#I#I#K#KLL 	%"$$$"8,,L**+++++rf   c                   | j         j        j        }|r3| j         j        j        s0| j         j        j        s| j         j        j        st                      | j         j        j        }|rt          |||d           | j         j        j        }|rt          || j	        |d           | j         j        j        }|rt          || j
        |d           dS dS )r   r   z	external z	internal N)r   r  r   r
  r   ext_import_graphint_import_graphr   r   r  _internal_dependencies_info)r  r   r?  r  r   r   s         rd   r   z)ImportsChecker._report_dependencies_graph  s     ;$1 	%K+	%{!2	% {!2	%
 #$$$;%2 	6(D"555;%6 	W$"BD+VVV;%6 	W$"BD+VVVVV	W 	Wrf   internalc                0   t          t                    }| j        j        j                                        D ]]\  }}|D ]U}| j                            ||          }|                    |          }|r|s|s|s||         	                    |           V^|S )z4Build the internal or the external dependency graph.)
r   r   r   r  r   r   r   getrj  rZ  )r  r  r  importee	importersimporterr8  	is_insides           rd   _filter_dependencies_graphz)ImportsChecker._filter_dependencies_graph  s    ,7,<,<#';#4#A#G#G#I#I 	2 	2Hi% 2 2*..xBB$//88	 2 2 28 2(O''111	2
 rf   c                .    |                      d          S )zYReturn cached external dependencies information or build and
        cache them.
        Fr  r  r  s    rd   r  z*ImportsChecker._external_dependencies_info  s    
 ...>>>rf   c                .    |                      d          S )zYReturn cached internal dependencies information or build and
        cache them.
        Tr  r  r  s    rd   r  z*ImportsChecker._internal_dependencies_info  s    
 ...===rf   rM  c                    |                                 j        rd S |                     |          }|j        D ]*\  }}|dk    r|s|                     d|j        |           +d S )Nrh   r   rB  )rv  r8  _wildcard_import_is_allowedrp   r  rr   )r  rP   rM  wildcard_import_is_allowedrS   r?  s         rd   rR  z&ImportsChecker._check_wildcard_imports!  s     99;; 	F%)%E%Eo%V%V"z 	R 	RGD!s{{#={  !2D QQQ	R 	Rrf   c                >    | j         j        j        o|d uod|j        v S )N__all__)r   r
  allow_wildcard_with_alllocals)r  rM  s     rd   r  z*ImportsChecker._wildcard_import_is_allowed-  s/    K6 4t+4_33	
rf   c                    t                                          t          j                  rdS fdj        D             } fd|D             }|r-                     dd                    |                     dS dS )z=Check whether the import is made outside the module toplevel.Nc                x    g | ]6}t          t          j                  rj         d |d          n|d         7S r  )rm   r   rq   rr   r  s     rd   r@  z2ImportsChecker._check_toplevel.<locals>.<listcomp>;  s]     
 
 
  $ 011t|''d1g'''a
 
 
rf   c                &    g | ]}|j         v|S r`   )r   )ra   rS   r  s     rd   r@  z2ImportsChecker._check_toplevel.<locals>.<listcomp>C  s-     
 
 
T9U-U-UD-U-U-Urf   r   rA  rB  )rm   rk   r   rI  rp   r  r   )r  rP   module_namesscoped_importss   ``  rd   rE  zImportsChecker._check_toplevel4  s     djjllEL11 	F
 
 
 
 
	
 
 

 
 
 
)
 
 
  	)		.0I0IPT      	 	rf   r   r!   rZ   r   )rZ   r   )rZ   r  )rZ   r"  )r   r!   r   r&  rZ   r   )rZ   r,  )rP   r6  rZ   r   )rP   r;  rZ   r   )rP   rO  rZ   r   )rP   re  rZ   r   )rP   rt  rZ   r   )rP   r   rZ   r   )rP   r   r  r  rZ   r   )rP   r   r   r  rZ   r}   )r  r6  rZ   r  )r  r   rr   rT   rZ   r  )rP   r   r  rT   rZ   r   )rP   r   r  rT   rZ   r   ri   )rP   r   r   rV   rW   rX   rZ   r   )r   r   r?  r    r  r  rZ   r   )r  r}   rZ   r  )rP   rO  rM  r  rZ   r   )rM  r  rZ   r}   ):__name__
__module____qualname____doc__rS   r   DEPRECATED_MODULE_MESSAGEr   msgsdefault_deprecated_modulesDEFAULT_PREFERRED_MODULESDEFAULT_STANDARD_LIBRARYDEFAULT_KNOWN_THIRD_PARTYoptionsr   r  r  r!  r%  r+  r.  r:  rN  rU  rd  rs  	visit_tryvisit_assignattrvisit_assignvisit_ifexpvisit_comprehension
visit_exprvisit_ifrw  visit_classdef	visit_forvisit_whilerQ  rS  rJ  rK  staticmethodr  rX  rH  rL  rG  rD  rC  r   r   r  r   r  r  rR  r  rE  r`   rf   rd   r   r   D  s         D@o7@4@D!# !5&)	 		
  46)	 		
 &9	 
	
 &9	 
	
 &9	 
	
 %3&8	 		
  4&)	 		
 %&) 	
 & %R	 	
 * %T	 	
hGTL L L LV V V V"   K K K K4 4 4 4   & & & &4 4 4 4B B B B2F F F F8+ + + +@!+ !+ !+ !+R 7TTI TT 	T
 	T 	T )8+ + + +, 0A@N@Y   X X X X   &9 9 9 92 X X X \Xc< c< c< c<J   @"H "H "H "HH   6   6  $ 	    :, , , ,W W W W*	 	 	 	 ? ? ? _? > > > _>
R 
R 
R 
R
 
 
 
     rf   r   r   r!   c                J    |                      t          |                      d S r  )register_checkerr   )r   s    rd   registerr  M  s$    
N62233333rf   )rP   r   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rV   rZ   r[   )rP   r   rr   rT   r{   r|   rZ   r}   )r   r   rZ   r   r  )r   r   r   rV   rZ   rT   )r   rT   r   r   rZ   rT   )
r   rT   r   r   r   r   r   rT   rZ   r   r  )Dr  ry  r   r  r  r   r0  r   collections.abcr   r   	functoolsr   typingr   r	   r
   r   r   rs   r   astroid.nodes._base_nodesr   pylint.checkersr   r   pylint.checkers.utilsr   r   r   r   r   r   pylint.exceptionsr   pylint.graphr   r   pylint.interfacesr   pylint.reporters.ureports.nodesr   r   r   pylint.typingr   pylint.utilsr   pylint.utils.linterstatsr    pylint.lintr!   rT   r   r/  rz   r   r   r   r   r   r   __annotations__r  r  r  r   r  r`   rf   rd   <module>r"     s  
 ( ' ' " " " " " "      				 



 # # # # # # / / / / / / / / % % % % % % 8 8 8 8 8 8 8 8 8 8 8 8 8 8        0 0 0 0 0 0 8 8 8 8 8 8 8 8                / . . . . . / / / / / / / / " " " " " " L L L L L L L L L L 0 0 0 0 0 0 $ $ $ $ $ $ 0 0 0 0 0 0 %$$$$$$
 3d4S>2DI=>>? x(|()w}000{888777  " " J4 4 4 4n5 5 5 5*       (& & & &&X X X XZ+>	456	Z+  Z+  Z+$  %Z+4  5Z+>  ?Z+H  IZ+R  SZ+\  ]Z+h  iZ+r  sZ+~  Z+H  IZ+R  SZ+^  _Z+j  kZ+ Z Z Z Zz  (  F F F F F_k F F FR4 4 4 4 4 4rf   