bg}UdZddlmZddlZddlmZddlmZmZm Z m Z m Z ddl Z ddl m Z mZddlmZddlmZdd lmZmZmZdd lmZdd lmZerdd lmZe e eeefe efZd Z e dzZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(ddhZ)dZ*hdZ+ddhZ,ddddiddd dd!dd"dd#dd$dd%dd&d'd(d)d*d+d,d-d.d/d0d-d1d-d2d-d3d-d4d-d5d6d6d7d7d8d8d9d:d;id<Z-d=e.d><d?hhd@dAhdBZ/dCe.dD<dEhdFihdGhdHdIhdJhdKhdLhdMhdNdOhhdPdQdRhhdShdThdUhdVhdWdX dYZ0dZe.d[<d\d]d^hid_hd`dahhdbdcdddehidfhdghdhdiZ1dje.dk<dwdpZ2GdqdreeZ3dxdvZ4dS)yz0Checkers for various standard library functions.) annotationsN)Iterable) TYPE_CHECKINGAnyDictSetTuple)nodesutil)InferenceResult) interfaces) BaseCheckerDeprecatedMixinutils) INFERENCE)MessageDefinitionTuple)PyLinter)openfile) read_text write_textz unittest.casezthreading.Threadz copy.copyz os._Environ)z os.getenvzsubprocess.Popenzsubprocess.run_iopathlib)zbuiltins.breakpointzsys.breakpointhookz pdb.set_trace>functools.lru_cache$functools._lru_cache_wrapper.wrapper'functools.lru_cache.decorating_functionzbuiltins.staticmethodzbuiltins.classmethod))Nx)intboolfloatzasyncio.tasks.sleep))Nloopzasyncio.tasks.gatherzasyncio.tasks.shieldzasyncio.tasks.wait_forzasyncio.tasks.waitzasyncio.tasks.as_completedz)asyncio.subprocess.create_subprocess_execz*asyncio.subprocess.create_subprocess_shell))r!zgettext.translation))codesetzgettext.install))r$zfunctools.partialmethod)Nfunczweakref.finalize)r&)Nobjzprofile.Profile.runcallzcProfile.Profile.runcallzbdb.Bdb.runcallztrace.Trace.runfunczcurses.wrapper))Nfunction))Nfn))Ncallback))Nc)Ntypeid)z!unittest.case.TestCase.addCleanupz3concurrent.futures.thread.ThreadPoolExecutor.submitz5concurrent.futures.process.ProcessPoolExecutor.submitz"contextlib._BaseExitStack.callbackz-contextlib.AsyncExitStack.push_async_callbackz&multiprocessing.managers.Server.createz2multiprocessing.managers.SharedMemoryServer.createzrandom.Random.shuffle))random)rrrrr2 rzIdict[tuple[int, int, int], dict[str, tuple[tuple[int | None, str], ...]]]DEPRECATED_ARGUMENTSzasyncio.coroutine>abc.abstractpropertyabc.abstractclassmethodabc.abstractstaticmethodz importlib.util.module_for_loader)r1r2r2rr2r"rDeprecationDictDEPRECATED_DECORATORSr0> cgi.parse_qs cgi.parse_qslctypes.c_buffertkinter.Misc.tk_menuBar tkinter.Menu.tk_bindForTraversal,distutils.command.sdist.sdist.check_metadata2distutils.command.register.register.check_metadata> os.popen2 os.popen3 os.popen4commands.getstatusmacostools.touched> unittest.case.TestCase.assert_#unittest.case.TestCase.assertEquals&unittest.case.TestCase.assertNotEquals)unittest.case.TestCase.assertAlmostEquals,unittest.case.TestCase.assertNotAlmostEquals'xml.etree.ElementTree.XMLParser.doctype)xml.etree.ElementTree.Element.getchildren)xml.etree.ElementTree.Element.getiterator+xml.etree.ElementTree.XMLParser.getiterator))r%r)r%r>inspect.getargspecfailIfassert_ failUnless failIfEqual assertEqualsassertNotEqualsfailUnlessEqualfailUnlessRaisesfailIfAlmostEqualassertAlmostEqualsassertRaisesRegexpassertRegexpMatchesassertNotAlmostEqualsfailUnlessAlmostEqualassertNotRegexpMatches>ntpath.splituncos.path.splituncbase64.decodestringbase64.encodestringos.stat_float_timesturtle.RawTurtle.settiltangle> cgi.escape#configparser.RawConfigParser.readfprOrPrQrR> time.clock logging.warnplatform.popenlogging.Logger.warninspect.getmoduleinfonntplib._NNTPBase.xpathsqlite3.OptimizedUnicodelogging.LoggerAdapter.warn> plistlib.readPlistplistlib.writePlistimportlib.find_loaderplistlib.writePlistToBytesplistlib.readPlistFromBytes importlib.abc.Loader.load_module importlib.abc.Loader.module_repr)importlib.abc.PathEntryFinder.find_loader)importlib.abc.PathEntryFinder.find_modulezasyncio.tasks.async> fractions.gcd platform.distinspect.getcallargsinspect.formatargspecplatform.linux_distributionz4importlib._bootstrap_external.FileLoader.load_modulez_ssl.RAND_pseudo_bytes> aifc.openfp wave.openfp sunau.openfp locale.formatssl.wrap_socketssl.match_hostnameasyncio.Task.all_taskasyncio.Task.current_tasksys.get_coroutine_wrappersys.set_coroutine_wrapperthreading.Thread.isAlive>gettext.lgettextgettext.ldgettextgettext.lngettextgettext.ldngettextgettext.bind_textdomain_codeset'gettext.NullTranslations.output_charset+gettext.NullTranslations.set_output_charsetr>binascii.a2b_hqxbinascii.b2a_hqxbinascii.rlecode_hqxbinascii.rledecode_hqx>cgi.logpathlib.Path.link_tothreading.Event.isSetthreading.activeCountthreading.currentThreadthreading.Thread.getNamethreading.Thread.setNamethreading.Thread.isDaemonthreading.Thread.setDaemon_sqlite3.enable_shared_cachethreading.Condition.notifyAll importlib.abc.Finder.find_module!zipimport.zipimporter.find_loader!zipimport.zipimporter.find_module!zipimport.zipimporter.load_module> re.templatelocale.resetlocaleunittest.makeSuiteunittest.findTestCaseslocale.getdefaultlocaleunittest.getTestCaseNames$unittest.TestLoader.getTestCaseNames'unittest.TestLoader.loadTestsFromModule)unittest.TestLoader.loadTestsFromTestCase) )r2rr)r2r.rr2r%rr:r;)r2r"r")r2r#r)r2rSr)r2rTrr1r4)r2 rr2 r)rr%r2zdict[int, DeprecationDict]DEPRECATED_METHODS configparserLegacyInterpolationSafeConfigParserFinder ImpImporter ImpLoader>rSizedMappingCallableHashablerIteratorKeysViewSequence Awaitable Container Coroutine Generator ItemsView ByteString Collection MutableSet Reversible ValuesView MappingView AsyncIterable AsyncIteratorAsyncGeneratorMutableMappingMutableSequence)z importlib.abcpkgutil collectionssmtpd MailmanProxyTextMacOSX)typing webbrowser)rr:r4rz/dict[tuple[int, int, int], dict[str, set[str]]]DEPRECATED_CLASSESmoderreturnrcPt|tsdSt|}d}d|v}|t|z s t|t|krdSd|v}d|v}d|v}d|v}d|v}d |vr |s|s|rdSd }|r|rdS||z|z|z} | d krdS|s|s|s|sdSd S) NFzrwatb+UxrrwatbUTr.) isinstancestrsetlen) rmodes_modecreatingreadingwriting appendingtextbinarytotals g/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pylint/checkers/stdlib.py_check_mode_strr?s dC u IIE Ee|H s5zzSYYU33uUlGUlGu I %dcd@ZdcdAZdcdBZdddEZdedGZdfdKZdgdLZdhdRZdidTZdjdWZ dkdZZ!dld[Z"d\S)m StdlibCheckerstdlib)z""%s" is not a valid mode for open. bad-open-modezPython supports: r, w, a[, x] modes with b, +, and U (only with r) options. See https://docs.python.org/3/library/functions.html#openz)Using datetime.time in a boolean context.boolean-datetimezUsing datetime.time in a boolean context can hide subtle bugs when the time they represent matches midnight UTC. This behaviour was fixed in Python 3.5. See https://bugs.python.org/issue13936 for reference. maxversion)r2r#)z*Redundant use of %s with constant value %rredundant-unittest-assertzThe first argument of assertTrue and assertFalse is a condition. If a constant is passed as parameter, that condition will be always true. In this case a warning should be emitted.)z*threading.Thread needs the target functionbad-thread-instantiationzThe warning is emitted when a threading.Thread class is instantiated without the target function being passed as a kwarg or as a second argument. By default, the first parameter is the group param, not the target param.)z;Using copy.copy(os.environ). Use os.environ.copy() instead.shallow-copy-environzos.environ is not a dict object but proxy object, so shallow copy has still effects on original object. See https://bugs.python.org/issue15373 for reference.)z$%s does not support %s type argumentinvalid-envvar-valuezwEnv manipulation functions support only string type arguments. See https://docs.python.org/3/library/os.html#os.getenv.)z[singledispatch decorator should not be used with methods, use singledispatchmethod instead.singledispatch-methodzrsingledispatch should decorate functions and not class/instance methods. Use singledispatchmethod for those cases.)z]singledispatchmethod decorator should not be used with functions, use singledispatch instead.singledispatchmethod-functionzrsingledispatchmethod should decorate class/instance methods and not functions. Use singledispatch for those cases.)z,%s default type is %s. Expected str or None.invalid-envvar-defaultzEnv manipulation functions return None or str values. Supplying anything different as a default may cause bugs. See https://docs.python.org/3/library/os.html#os.getenv.)zGUsing preexec_fn keyword which may be unsafe in the presence of threadssubprocess-popen-preexec-fna0The preexec_fn parameter is not safe to use in the presence of threads in your application. The child process could deadlock before exec is called. If you must use it, keep it trivial! Minimize the number of libraries you call into. See https://docs.python.org/3/library/subprocess.html#popen-constructor)zH'subprocess.run' used without explicitly defining the value for 'check'.subprocess-run-checkzThe ``check`` keyword is set to False by default. It means the process launched by ``subprocess.run`` can exit with a non-zero exit code and fail silently. It's better to set it explicitly to make clear what the error-handling behavior is.)z4Using open without explicitly specifying an encodingunspecified-encodingzIt is better to specify an encoding when opening documents. Using the system default implicitly can create problems on other operating systems. See https://peps.python.org/pep-0597/)zLLeaving functions creating breakpoints in production code is not recommendedforgotten-debug-statementzCalls to breakpoint(), sys.breakpointhook() and pdb.set_trace() should be removed from code that is not actively being debugged.zc'lru_cache(maxsize=None)' or 'cache' will keep all method args alive indefinitely, including 'self'method-cache-max-size-noneaOBy decorating a method with lru_cache or cache the 'self' argument will be linked to the function and therefore never garbage collected. Unless your instance will never need to be garbage collected (singleton) it is recommended to refactor code to avoid this pattern or add a maxsize to the cache. The default value for maxsize is 128. old_names)W1516zlru-cache-decorating-method)W1517zcache-max-size-none)W1501W1502W1503W1506W1507E1507E1519E1520W1508W1509W1510W1514W1515W1518z!dict[str, MessageDefinitionTuple]msgslinterrrNonec tj||t|_i|_i|_t|_ttj d D]/\}}|tj kr|j |0t D]/\}}|tj kr|j |0t D]/\}}|tj kr|j |0t D]/\}}|tj kr|j |0dS)Nr)r__init__r_deprecated_methods_deprecated_arguments_deprecated_classes_deprecated_decoratorsrsys version_infoitemsupdater6rr=)selfr since_vers func_list args_list class_listdecorator_lists rrzStdlibChecker.__init__spT6***-0UU TV"8: 03#%78H8K%L%R%R%T%T ; ; !J S---(// :::%9%?%?%A%A = = !J S---*11)<<<&8&>&>&@&@ < < "J S---(// ;;;*?*E*E*G*G C C &JS---+22>BBB C Crnode nodes.Callcd|jD}d|vrdSt|jdkr/|jrd|vr&|d|t jdSdSdS)Nch|] }|j Sarg).0keys r z@StdlibChecker._check_bad_thread_instantiation..s8883sw888rtargetr%rr+ confidence)keywordsrargskwargs add_messager HIGH)r%r+ func_kwargss r_check_bad_thread_instantiationz-StdlibChecker._check_bad_thread_instantiations88$-888 { " " F ty>>A  t{ hk6Q6Q   **/        6Q6Qrcp|jr,|jD]&}|jdkr|d|%dSdS)N preexec_fnrr+)r8r1r;)r%r+keywords r_check_for_preexec_fn_in_popenz,StdlibChecker._check_for_preexec_fn_in_popens` = O= O O;,..$$%B$NNN O O O Orcrd|jpdD}d|vr|d|tdSdS)Nch|] }|j Sr/r0r2rBs rr4z;StdlibChecker._check_for_check_kw_in_run..sCCC''+CCCrr/checkrr6)r8r;r)r%r+r:s r_check_for_check_kw_in_runz(StdlibChecker._check_for_check_kw_in_runsQCCdm.ArCCC &   3$9  U U U U U ! rctj|d} |}n#tj$rYdSwxYw|D]9}|t kr|d|dS:dS)Nr)positionrrA)rget_argument_from_callinferredastroidInferenceErrorqname OS_ENVIRONr;)r%r+r1 inferred_argsrLs r_check_shallow_copy_environz)StdlibChecker._check_shallow_copy_environs*4!<<< LLNNMM%    FF %  H~~:--  !7d CCC.  s-AArrzdeprecated-methodzdeprecated-argumentrrrrrrzdeprecated-classrrc||tj|jD]O}t |t jr|jtvrd}t |jtj r |jj}t |jtj r |jj }|tvr.|||j|nj|jt kr|||n0t |tjrf|t(kr||n|t,kr||nt |tjr|}|t2kr||na|t6vr|||nA|t:kr||n |t>vr| d||!||QdS)zVisit a Call node.NrrA)"check_deprecated_class_in_callr infer_allr'rr UninferableBaserootname OPEN_MODULEr Name AttributeattrnameOPEN_FILES_FUNCS_check_open_call UNITTEST_CASE_check_redundant_assertClassDefrOTHREADING_THREADr>SUBPROCESS_POPENrC FunctionDef COPY_COPYrR ENV_GETTERS_check_env_functionSUBPROCESS_RUNrHDEBUG_BREAKPOINTSr;check_deprecated_method)r%r+rLopen_func_namerXs r visit_callzStdlibChecker.visit_call sG" ++D111 22 9 9H(D$899 }}#{22-1di444%)Y^Ndi998%)Y%7N!%555))$ 0DnUUU%66,,T8<<<<Hen55 M>>##'77788>>>>^^%%)99977===He&788 M~~''9$$44T::::[((,,T8<<<<^++33D9999...$$%@t$LLL  ( (x 8 8 8 89 9 9r nodes.UnaryOpcT|jdkr||jdSdS)Nnot)op_check_datetimeoperandr%r+s r visit_unaryopzStdlibChecker.visit_unaryop<s3 7e     . . . . .  rnodes.Ifc:||jdSNrqtestrss rvisit_ifzStdlibChecker.visit_ifA TY'''''r nodes.IfExpc:||jdSrwrxrss r visit_ifexpzStdlibChecker.visit_ifexpEr{r nodes.BoolOpcD|jD]}||dSrw)valuesrq)r%r+values r visit_boolopzStdlibChecker.visit_boolopIs4[ ( (E   ' ' ' ' ( (rrrnodes.FunctionDefc|jrKt|jtjr.||||dSdSdSrw) decoratorsrparentr ra_check_lru_cache_decorators_check_dispatch_decoratorsrss rvisit_functiondefzStdlibChecker.visit_functiondefNse ? 2z$+u~FF 2  , ,T 2 2 2  + +D 1 1 1 1 1 2 2 2 2rctd|jDrdSg}|jjD]} |D]}|}|tvrdS|tvrt|tj ri tj |dd}n#tj $rYn\wxYwt|tjr|jn5||n|dkr||n͌#t"j$rYwxYw|D]$}|d|t(j%dS) zACheck if instance methods are decorated with functools.lru_cache.c3>K|]}tj|VdSrw)ris_enum)r2ancestors r z.Zs,OO8u}X&&OOOOOOrNrmaxsizerJrBzfunctools.cacherr6)anyr ancestorsrr inferrONON_INSTANCE_METHODS LRU_CACHErCallrrKNoSuchArgumentErrorConstrappendrMrNr;r r)r%r+lru_cache_nodesd_node infered_nodeq_namer1lru_cache_nodes rrz)StdlibChecker._check_lru_cache_decoratorsXs OOt{7L7L7N7NOOO O O  F.0o+  F $*LLNNL)//11F!555**z&%*/M/M*""'"> &I###CC %8"""!EE" *#u{;;"sy?T!E'..v666!222'..v6663)    -  N   ,#%/       s=4D&;#D&B76D&7C D& C  AD&&D87D8ci}|jjD]}t|tjr|jr|t jf||j<:tj|r|t j f|d<`tj |r|t j f|d<d|vr6d|vr2| d|dd|dddSd|vr6d|vr4| d |dd|dddSdSdS) Nsingledispatchsingledispatchmethod classmethodrrr.r6 staticmethodr) rr rrZrXr r<r(is_registered_in_singledispatch_functionr.is_registered_in_singledispatchmethod_functionr;)r%r+decorators_map decorators rrz(StdlibChecker._check_dispatch_decoratorssjPR.  I)UZ00 Y^ 2;Z_1My~..?EE 4=z?S3T/00EdKK (:56 ~ - -->2Q2Q   '#$45a8)*:;A>       #n 4 4.00   /#$:;A>)*@A!D       5 400rrr ct|tjrf|jrat|jdtjr>|jdvr7|d|j|jdjf|dSdSdSdSdS)Nr> assertTrue assertFalser)r9r+) rrM BoundMethodr9r rrXr;r)r%r+rs rr`z%StdlibChecker._check_redundant_asserts ug1 2 2   49Q<55  ;;;   +j$)A,"45            <;r nodes.NodeNGc t|}n#tj$rYdSwxYwt |tjr1|dkr|d|dSdSdS)zICheck that a datetime was inferred, if so, emit boolean-datetime warning.Nz datetime.timerrA)nextrrMrNrInstancerOr;)r%r+rLs rrqzStdlibChecker._check_datetimes DJJLL))HH%    FF  x!1 2 2 <  O33   /d  ; ; ; ; ;  < <33s !$77 open_moduler func_namec:d} |dkrtj|dd}n|dkrtj|dd}n#tj$rYnwxYw|r|tj|}|tvr_t |t jrEt|j s1| d||j pt|j  |r9t |t jr#|j rd t|j vrd} |dkrh|j j d krtj|dd }nW|j j d krtj|dd }n/tj|dd }ntj|dd }n,#tj$r| d|YnwxYw|rRtj|}t |t jr&|j !| d|dSdSdSdSdSdS)z Various checks for an open call.Nrr.rrrrrr+r9rrencodingrr%r2rrA)rrKr safe_inferOPEN_FILES_MODErr rrrr;rr'r\)r%r+rrmode_arg encoding_args rr^zStdlibChecker._check_open_calls e## 71f )) 71f(    D   '11H_,,x55-'77-  #!>3x~+>+>! H(EK00 H^ H(+#hn2E2E'E'EL D)++y)[88','C 1j((( +|;;','C 1j((( (-'C 1j((( $)#?q*$$$L, D D D  !7d CCCCC D H$/ == lEK88H\=O=W$$%;$$GGGGG? H H(F'E0 H HHH=W=Ws$;AAABF&G?Gcd}d}|jrd|jD}nd}|jr|jd}n|r ||vr ||}nd}|r,||dtj||dt |jdkr|jd }n|r ||vr ||}nd}|r.|||d tj|d dSdS) Nr3defaultc(i|]}|j|jSr/)r1rrFs r z5StdlibChecker._check_env_function..sNNNWgk7=NNNrrrF)r+messagecall_argr allow_noner%r.rT)r+rrrr)r8r9_check_invalid_envvar_valuerrr)r%r+renv_name_kwargenv_value_kwargr: env_name_arg env_value_args rrgz!StdlibChecker._check_env_functionsC# = NN NNNFFF 9 9Q>Q   IaLMM  !611"?3MM M    , ,0)-88 -       rrrInferenceResult | Nonerrc|t|tjrdS|}t|tjr[d}|j| }nt|jtsd}|r.||||| fdSdS||||| fdS)NFTr) rr rVrOr rrrr;pytype)r%r+rrrrrXemits rrz)StdlibChecker._check_invalid_envvar_value s  z(D4HII  F{{}} h , , QD~%%~44  U  t4ARAR:S TTTTT U U   W4tX__=N=N6O  P P P P Prset[str]c|jSrw)rr%s rdeprecated_methodsz StdlibChecker.deprecated_methods7s ''rmethod"tuple[tuple[int | None, str], ...]c8|j|dSNr/)rget)r%rs rdeprecated_argumentsz"StdlibChecker.deprecated_arguments:s)--fb999rmodule Iterable[str]c8|j|dSr)rr)r%rs rdeprecated_classesz StdlibChecker.deprecated_classes=s'++FB777rc|jSrw)r rs rdeprecated_decoratorsz#StdlibChecker.deprecated_decorators@s **rNrrrr)r+r,rr)r+rmrr)r+rurr)r+r|rr)r+rrr)r+rrr)r+r,rr rr)r+rrr)r+r,rrrrrr)r+r,rrrr) r+r,rrrrrrrrrr)rr)rrrr)rrrr)rr)#__name__ __module__ __qualname__rXrDEPRECATED_METHOD_MESSAGEDEPRECATED_ARGUMENT_MESSAGEDEPRECATED_CLASS_MESSAGEDEPRECATED_DECORATOR_MESSAGEr__annotations__rr>rCrHrRronly_required_for_messagesrlrtrzr~rrrrr`rqr^rgrrrrrr/rrrr]s Dt/  3t/  5t/  2t/  6 t/   8  D6 "              r ( 4 <4  Kt/t/t/DttttlCCCC,OOOO VVVV    &U%#" %#9999B&U%&899///:9/&U%&899(((:9(&U%&899(((:9(&U%&899(((:9(&U%$' 222  2 ((((T<     < < < <>H>H>H>H@%%%%NQQQQ.((((::::8888++++++rrrrrcJ|t|dSrw)register_checkerr)rs rregisterrDs$ M&1122222r)rrrrr)5__doc__ __future__rr!collections.abcrrrrrrr rMr r astroid.typingr pylintr pylint.checkersrrrpylint.interfacesr pylint.typingr pylint.lintrrrr<rr]r_rbrerPrfrcrhrYrirrr6rr=rrrrrr/rrrsJ 766"""""" $$$$$$77777777777777******??????????''''''000000%$$$$$$uS#s]+SX56""%@@ %    %!i R    01GH 0 1  1 !"3  /  %&7  45F 5n 0 , "#4 ; "#4 #$5 , 0!" +#$.C?NAP.C9N2Q? 1:()9:G$$&&&&R$$ 33**            *   $              **    C $               "    e}}A^2^2^^^^F  !          ##J       a8G8G8888v