bg%dZddlmZddlmZmZddlmZddlZddlm Z ddl m Z ddl m Z dd lmZmZmZdd lmZejeje je jfZGd d e ZdS) z+Checker mixin for deprecated functionality.) annotations) ContainerIterable)chainN)nodes)utils) BaseChecker)get_import_name infer_all safe_infer)MessageDefinitionTupleceZdZUdZdddddgddfiZd ed <d d d ddgddfiZd ed<dddddgddfiZd ed<dddddgddfiZd ed<dddd d!gddfiZ d ed"<e j d dddDd'Z e j dddEd)Z dFd+Ze j ddGd-Ze j dddHd/ZdId1ZdJd5ZdFd6ZdKd8ZdLd;ZdMd>ZdNdAZdDdBZdCS)ODeprecatedMixinzA mixin implementing logic for checking deprecated symbols. A class implementing mixin must define "deprecated-method" Message. W4901zDeprecated module %rdeprecated-modulez*A module marked as deprecated is imported.)W0402zold-deprecated-moduleT) old_namessharedz!dict[str, MessageDefinitionTuple]DEPRECATED_MODULE_MESSAGEW4902zUsing deprecated method %s()deprecated-methodzEThe method is marked as deprecated and will be removed in the future.)W1505zold-deprecated-methodDEPRECATED_METHOD_MESSAGEW4903z+Using deprecated argument %s of method %s()deprecated-argumentzGThe argument is marked as deprecated and will be removed in the future.)W1511zold-deprecated-argumentDEPRECATED_ARGUMENT_MESSAGEW4904z&Using deprecated class %s of module %sdeprecated-classzDThe class is marked as deprecated and will be removed in the future.)W1512zold-deprecated-classDEPRECATED_CLASS_MESSAGEW4905zUsing deprecated decorator %s()deprecated-decoratorzHThe decorator is marked as deprecated and will be removed in the future.)W1513zold-deprecated-decoratorDEPRECATED_DECORATOR_MESSAGEnode nodes.CallreturnNonec||t|jD]}|||dS)z2Called when a :class:`nodes.Call` node is visited.N)check_deprecated_class_in_callr funccheck_deprecated_method)selfr&inferreds k/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pylint/checkers/deprecated.py visit_callzDeprecatedMixin.visit_callOsT ++D111!$),, 9 9H  ( (x 8 8 8 8 9 9 nodes.Importcd|jDD]M}|||d|vr1|dd\}}||||fNdS)z+Triggered when an import statement is seen.c3 K|] \}}|V dSN.0name_s r0 z/DeprecatedMixin.visit_import..as&44gdAT444444r2.N)namescheck_deprecated_modulesplitcheck_deprecated_class)r.r&r:mod_name class_names r0 visit_importzDeprecatedMixin.visit_import[s 54444 K KD  ( (t 4 4 4d{{'+zz#q'9'9$*++D(ZMJJJ  K Kr2 Iterable[str]cdS)zCallback returning the deprecated decorators. Returns: collections.abc.Container of deprecated decorator names. r7r7r.s r0deprecated_decoratorsz%DeprecatedMixin.deprecated_decoratorsh rr2nodes.Decoratorsct|}|sdSt|dtjrt |dj}nt |d}|r|nd}||vr| d||dSdS)z-Triggered when a decorator statement is seen.Nrr#r&args) list get_children isinstancerCallr r,qnamerI add_message)r.r&childreninfrSs r0visit_decoratorsz DeprecatedMixin.visit_decoratorsps))++,,  F hqk5: . . *Xa[-..CCXa[))C",  D..00 0 0   3$U  K K K K K 1 0r2nodes.ImportFromc|j}t||}|||d|jD}||||dS)z(Triggered when a from statement is seen.c3 K|] \}}|V dSr6r7r8s r0r<z3DeprecatedMixin.visit_importfrom..s&66at666666r2N)modnamer r@r?rB)r.r&basename class_namess r0visit_importfromz DeprecatedMixin.visit_importfrom~sc <"422 $$T8444664:666  ##D(K@@@@@r2Container[str]cdS)zCallback returning the deprecated methods/functions. Returns: collections.abc.Container of deprecated function/method names. r7r7rHs r0deprecated_methodsz"DeprecatedMixin.deprecated_methodsrJr2methodstr Iterable[tuple[int | None, str]]cdS)aPCallback returning the deprecated arguments of method/function. Args: method (str): name of function/method checked for deprecated arguments Returns: collections.abc.Iterable in form: ((POSITION1, PARAM1), (POSITION2: PARAM2) ...) where * POSITIONX - position of deprecated argument PARAMX in function definition. If argument is keyword-only, POSITIONX should be None. * PARAMX - name of the deprecated argument. E.g. suppose function: .. code-block:: python def bar(arg1, arg2, arg3, arg4, arg5='spam') with deprecated arguments `arg2` and `arg4`. `deprecated_arguments` should return: .. code-block:: python ((1, 'arg2'), (3, 'arg4')) r7r7)r.rbs r0deprecated_argumentsz$DeprecatedMixin.deprecated_argumentss 0rr2cdS)zCallback returning the deprecated modules. Returns: collections.abc.Container of deprecated module names. r7r7rHs r0deprecated_modulesz"DeprecatedMixin.deprecated_modulesrJr2modulecdS)zCallback returning the deprecated classes of module. Args: module (str): name of module checked for deprecated classes Returns: collections.abc.Container of deprecated class names. r7r7)r.ris r0deprecated_classesz"DeprecatedMixin.deprecated_classess rr2mod_path str | Nonec|D]:}||ks|r0||dzr|d||;dS)z#Checks if the module is deprecated.r=rrMN)rh startswithrT)r.r&rlrCs r0r@z'DeprecatedMixin.check_deprecated_modulesp//11 P PH8##x#H4G4GSV4W4W#  !44h OOO P Pr2r/ nodes.NodeNGct|tsdSt|jtjr |jj}n.t|jtjr |jj}ndS||h}tfd|Dr d||fdSt|j }|j rd|j Dni}fd|D}t|D]F\}} | |vr d|| |f$| ||kr d|| |fGdS)zExecutes the checker for the given node. This method should be called from the checker implementing this mixin. Nc3DK|]}|vVdSr6)ra)r9r:r.s r0r<z:DeprecatedMixin.check_deprecated_method..s4DDTtt..000DDDDDDr2rrMch|] }|j Sr7)arg)r9kws r0 z:DeprecatedMixin.check_deprecated_method..s111R"&111r2c3BK|]}|VdSr6)rf)r9qnr.s r0r<z:DeprecatedMixin.check_deprecated_method..s1OO" 9 9" = =OOOOOOr2r)rQACCEPTABLE_NODESr,r AttributeattrnameNamer:rSanyrTlenrNkeywordsr) r.r&r/ func_nameqnames num_of_argskwargsrfpositionarg_names ` r0r-z'DeprecatedMixin.check_deprecated_methods($455  F di 1 1  *II  5: . .  II F..""I. DDDDVDDD D D    0t9,  O O O F$)nn 59]J114=1111OOOOOOO"')=">   Hh6!!  )Hi;P!%([*@*@  )Hi;P!  r2rCr]cr|D]3}|||vr|d|||f4dS)z"Checks if the class is deprecated.rrMN)rkrT)r.r&rCr]rDs r0rBz&DeprecatedMixin.check_deprecated_classs` &  JT44X>>>>  &TX8N!  r2ct|jtjr[t|jjtjr9|jjj}|jj}||||fdSdSdS)z$Checks if call the deprecated class.N) rQr,rrzexprr|r:r{rB)r.r&rCrDs r0r+z.DeprecatedMixin.check_deprecated_class_in_calls di 1 1 Gj INEJ7 7  Gy~*H+J  ' 'h F F F F F  G G G Gr2N)r&r'r(r))r&r3r(r))r(rF)r&rKr(r))r&rXr(r))r(r_)rbrcr(rd)rircr(rF)r&r3rlrmr(r))r&r'r/rpr(r))r&rprCrcr]rFr(r))__name__ __module__ __qualname____doc__r__annotations__rrr!r%ronly_required_for_messagesr1rErIrWr^rarfrhrkr@r-rBr+r7r2r0rrs  "  8=>$ O O  D  *  S=>$ O O  D  9 ! U?@D Q Q  F  4  R<= N N  C  - " V@AT R R  G &U% 999  9&U%KKK K&U%&<== L L L>= L&U%AAA A4    PPPP ####J    GGGGGGr2r)r __future__rcollections.abcrr itertoolsrastroidrpylint.checkersrpylint.checkers.base_checkerr pylint.checkers.utilsr r r pylint.typingr BoundMethod UnboundMethod FunctionDefClassDefryrr7r2r0rs! 21""""""////////!!!!!!444444HHHHHHHHHH000000    N bGbGbGbGbGkbGbGbGbGbGr2