Your IP : 216.73.216.196


Current Path : /opt/alt/python37/lib/python3.7/site-packages/pylint/checkers/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/pylint/checkers/__pycache__/python3.cpython-37.pyc

B

A!p\���@sPdZddlmZmZddlmZddlZddlZddlZddl	m
Z
ddlZddlmZddl
mZmZddlmZmZdd	lmZmZdd
lmZddlmZe�d�Zd
d�Zdd�Zdd�Zdddddddddddddd d!d"hZd#d$hZ d%d&d'hZ!d(d)d*hZ"d+d,�Z#d-d.�Z$ed/d0d1g�Z%Gd2d3�d3ej&�Z'Gd4d5�d5ej(�Z)d6d7�Z*dS)8z<Check Python 2 code for Python 2/3 source-compatible issues.�)�absolute_import�print_function)�
namedtupleN)�	FrozenSet)�bases)�checkers�
interfaces)�node_ignores_exception�find_try_except_wrapper_node)�INFERENCE_FAILURE�	INFERENCE)�WarningScope)�utilsz^0+$cCsFt�|�rdSt�d|�rByt|d�Wntk
r<dSXdSdS)NFz0\d+�T)�_ZERO�match�re�int�
ValueError)�literal�r�H/opt/alt/python37/lib/python3.7/site-packages/pylint/checkers/python3.py�
_is_old_octal0s
rcCs&t|tj�rdSt|tj�o$d|jkS)NT�dict)�
isinstance�astroid�Dict�InstanceZ	basenames)�valuerrr�_inferred_value_is_dict<srcCst|dd�dkS)N�name)�__builtin__�builtins)�getattr)�noderrr�_is_builtinBsr%�iter�list�tuple�sorted�set�sum�any�all�	enumerater�filter�reversed�max�min�	frozenset�OrderedDict�join�
from_iterablezbuiltins.list.extendzbuiltins.dict.updatezbuiltins.set.update�items�keys�valuescCsx|j}t|tj�rdSt|tj�r4|j|kr0dS�n.t|tj�r�t|jtj�r||j�	|jj
�d}t|�r�|jj
tkr�dSnt|jtj
�r�|jjtkr�dSt�|j�}|r�|��tkr�dS|��}|r�|j
dkr�dSn�t|tj��rt|jdtjtjf��rt|jdj�dk�rbdSnHt|tj��rPt|j�dk�rP|jdddk�rPdSt|tj��rbdSt|tj��rtdSdS)z{Check if the node is being used as an iterator.

    Definition is taken from lib2to3.fixer_util.in_special_context().
    Tr�	itertools��inF)�parentrrZForZ
Comprehensionr&ZCall�func�Name�lookupr r%�_ACCEPTS_ITERATOR�	Attribute�attrname�ATTRIBUTES_ACCEPTS_ITERATORr�
safe_infer�qname� _BUILTIN_METHOD_ACCEPTS_ITERATOR�rootZAssign�targets�List�Tuple�lenZelts�CompareZopsZ	YieldFromZStarred)r$r=Zparent_scope�inferredrHrrr�_in_iterating_contextasD
rOcCs |j}t|tjtjtjtjf�S)zAChecks if an import node is in the context of a conditional.
    )r=rrZ	TryExcept�
ExceptHandlerZIfZIfExp)r$r=rrr�_is_conditional_import�srQ�Branchr$�is_py2_onlycas�eZdZejZdZdZddddddd	gifd
dddd
gifdddej	dgd�fdddddifddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1dd2gifd3d4d5dd6gifd7d8d9d:d;d<d=d>d?d@dAdBddCgifdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^�CZ
ed_d`dadbdcdddedfdgdhdidjdkdldmdndodpg�Zedqdrdsdtdudvdwdxdydzd{g�Z
ed|d}d~dd�d�d�d�d�d�d�d�d�d�d�d�d�d�g�Zd�ed�g�id�ed�d�d�d�d�g�id�ed�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�g�ied�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d��d�d�d�d�d�d�d�d�d�d	�d
�d�dg]��d
e�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d �d!�d"�d#�d$�d%�d&�d'�d(�d)�d*�d+�d�d,�d-�d.�d/�d0g$�i�d1e�d2h�i�d3e�d4�d5�d6�d7�d8�d9�d:�d;�d<�d=�d>�d?�d@�dA�dB�dC�dD�dE�dF�dG�dH�dI�dJ�dK�dL�dM�dN�dO�dP�dQ�dR�dS�dT�dU�dV�dW�dX�dY�dZh'�id�e�d[h�i�d\�Z�d]ejk�r:�d^k�rFnne�Zne�d_�d`��daD��Z�f�db�dc�Z�d��f�dd�de�	Z�df�dg�Z�dh�di�Z�dj�dk�Z�dl�dm�Z�dn�do�Z�dp�dq�Z�dr�ds�Ze��dt��du�dv��Ze��dw��dx�dy��Z�dz�d{�Z e��d|��d}�d~��Z!�d��d��d��Z"�d��d��Z#�d��d��Z$e��d���d��d���Z%e��d���d��d���Z&�d��d��Z'e(�d��d���Z)e(�d��d���Z*e(�d��d���Z+e(�d��d���Z,�d��d��Z-�d��d��Z.e�d0��d��d���Z/�d��d��Z0�d��d��Z1e��d��d���d��d���Z2e�d�dw��d��d���Z3e�d��d��d���Z4e�d4d��d��d���Z5�d��d��Z6�Z7S(��Python3CheckerF�python3)zprint statement usedzprint-statementzGUsed when a print statement is used (`print` is a function in Python 3))zParameter unpacking specifiedzparameter-unpackingzTUsed when parameter unpacking is specified for a function(Python 3 doesn't allow it)z=Implicit unpacking of exceptions is not supported in Python 3zunpacking-in-exceptzwPython3 will not allow implicit unpacking of exceptions in except clauses. See http://www.python.org/dev/peps/pep-3110/�	old_names)ZW0712zunpacking-in-exceptz=Use raise ErrorClass(args) instead of raise ErrorClass, args.zold-raise-syntaxzZUsed when the alternate raise syntax 'raise foo, bar' is used instead of 'raise foo(bar)'.)ZW0121zold-raise-syntaxzUse of the `` operator�backtickzYUsed when the deprecated "``" (backtick) operator is used instead  of the str() function.)ZW0333rW)�scoperVz%Import * only allowed at module levelzimport-star-module-levelzNUsed when the import star syntax is used somewhere else than the module level.�
maxversion)�r)zapply built-in referencedz
apply-builtinzKUsed when the apply built-in function is referenced (missing from Python 3))zbasestring built-in referencedzbasestring-builtinzPUsed when the basestring built-in function is referenced (missing from Python 3))zbuffer built-in referencedzbuffer-builtinzLUsed when the buffer built-in function is referenced (missing from Python 3))zcmp built-in referencedzcmp-builtinzIUsed when the cmp built-in function is referenced (missing from Python 3))zcoerce built-in referencedzcoerce-builtinzLUsed when the coerce built-in function is referenced (missing from Python 3))zexecfile built-in referencedzexecfile-builtinzNUsed when the execfile built-in function is referenced (missing from Python 3))zfile built-in referencedzfile-builtinzJUsed when the file built-in function is referenced (missing from Python 3))zlong built-in referencedzlong-builtinzJUsed when the long built-in function is referenced (missing from Python 3))zraw_input built-in referencedzraw_input-builtinzOUsed when the raw_input built-in function is referenced (missing from Python 3))zreduce built-in referencedzreduce-builtinzLUsed when the reduce built-in function is referenced (missing from Python 3))z!StandardError built-in referencedzstandarderror-builtinzSUsed when the StandardError built-in function is referenced (missing from Python 3))zunicode built-in referencedzunicode-builtinzMUsed when the unicode built-in function is referenced (missing from Python 3))zxrange built-in referencedzxrange-builtinzLUsed when the xrange built-in function is referenced (missing from Python 3))z__coerce__ method definedz
coerce-methodzIUsed when a __coerce__ method is defined (method is not used by Python 3))z__delslice__ method definedzdelslice-methodzKUsed when a __delslice__ method is defined (method is not used by Python 3))z__getslice__ method definedzgetslice-methodzKUsed when a __getslice__ method is defined (method is not used by Python 3))z__setslice__ method definedzsetslice-methodzKUsed when a __setslice__ method is defined (method is not used by Python 3))z7import missing `from __future__ import absolute_import`zno-absolute-importztUsed when an import is not accompanied by ``from __future__ import absolute_import`` (default behaviour in Python 3))z!division w/o __future__ statementzold-divisionz�Used for non-floor division w/o a float literal or ``from __future__ import division`` (Python 3 returns a float for int division unconditionally))zCalling a dict.iter*() methodzdict-iter-methodz]Used for calls to dict.iterkeys(), itervalues() or iteritems() (Python 3 lacks these methods))zCalling a dict.view*() methodzdict-view-methodz]Used for calls to dict.viewkeys(), viewvalues() or viewitems() (Python 3 lacks these methods))z#Called a next() method on an objectznext-method-calledzZUsed when an object's next() method is called (Python 3 uses the next() built-in function))z.Assigning to a class's __metaclass__ attributezmetaclass-assignmentz�Used when a metaclass is specified by assigning to __metaclass__ (Python 3 specifies the metaclass as a class statement argument)z-Indexing exceptions will not work on Python 3zindexing-exceptionzSIndexing exceptions will not work on Python 3. Use `exception.args[index]` instead.)ZW0713zindexing-exceptionzRaising a string exceptionzraising-stringzGUsed when a string exception is raised. This will not work on Python 3.)ZW0701zraising-string)zreload built-in referencedzreload-builtinz�Used when the reload built-in function is referenced (missing from Python 3). You can use instead imp.reload or importlib.reload.)z__oct__ method definedz
oct-methodzGUsed when an __oct__ method is defined (method is not used by Python 3))z__hex__ method definedz
hex-methodzFUsed when a __hex__ method is defined (method is not used by Python 3))z__nonzero__ method definedznonzero-methodzJUsed when a __nonzero__ method is defined (method is not used by Python 3))z__cmp__ method definedz
cmp-methodzFUsed when a __cmp__ method is defined (method is not used by Python 3))zinput built-in referencedz
input-builtinzYUsed when the input built-in is referenced (backwards-incompatible semantics in Python 3))zround built-in referencedz
round-builtinzYUsed when the round built-in is referenced (backwards-incompatible semantics in Python 3))zintern built-in referencedzintern-builtinzMUsed when the intern built-in is referenced (Moved to sys.intern in Python 3))zunichr built-in referencedzunichr-builtinzAUsed when the unichr built-in is referenced (Use chr in Python 3)z*map built-in referenced when not iteratingzmap-builtin-not-iteratingzeUsed when the map built-in is referenced in a non-iterating context (returns an iterator in Python 3))ZW1631zimplicit-map-evaluation)z*zip built-in referenced when not iteratingzzip-builtin-not-iteratingzeUsed when the zip built-in is referenced in a non-iterating context (returns an iterator in Python 3))z,range built-in referenced when not iteratingzrange-builtin-not-iteratingzgUsed when the range built-in is referenced in a non-iterating context (returns an iterator in Python 3))z-filter built-in referenced when not iteratingzfilter-builtin-not-iteratingzhUsed when the filter built-in is referenced in a non-iterating context (returns an iterator in Python 3))z-Using the cmp argument for list.sort / sortedzusing-cmp-argumentz�Using the cmp argument for list.sort or the sorted builtin should be avoided, since it was removed in Python 3. Using either `key` or `functools.cmp_to_key` should be preferred.)z6Implementing __eq__ without also implementing __hash__zeq-without-hashz�Used when a class implements __eq__ but not __hash__.  In Python 2, objects get object.__hash__ as the default implementation, in Python 3 objects get None as their default __hash__ implementation if they also implement __eq__.)z__div__ method definedz
div-methodz�Used when a __div__ method is defined.  Using `__truediv__` and setting__div__ = __truediv__ should be preferred.(method is not used by Python 3))z__idiv__ method definedzidiv-methodz�Used when an __idiv__ method is defined.  Using `__itruediv__` and setting__idiv__ = __itruediv__ should be preferred.(method is not used by Python 3))z__rdiv__ method definedzrdiv-methodz�Used when a __rdiv__ method is defined.  Using `__rtruediv__` and setting__rdiv__ = __rtruediv__ should be preferred.(method is not used by Python 3))z%Exception.message removed in Python 3zexception-message-attributezYUsed when the message attribute is accessed on an Exception.  Use str(exception) instead.)z$non-text encoding used in str.decodezinvalid-str-codeczqUsed when using str.encode or str.decode with a non-text encoding.  Use codecs module to handle arbitrary codecs.)zsys.maxint removed in Python 3zsys-max-intz9Used when accessing sys.maxint.  Use sys.maxsize instead.)zModule moved in Python 3zbad-python3-importz?Used when importing a module that no longer exists in Python 3.)z4Accessing a deprecated function on the string modulezdeprecated-string-functionzKUsed when accessing a string function that has been deprecated in Python 3.)z:Using str.translate with deprecated deletechars parameterszdeprecated-str-translate-callzwUsed when using the deprecated deletechars parameters from str.translate.  Use re.sub to remove the desired characters )z7Accessing a deprecated function on the itertools modulezdeprecated-itertools-functionzNUsed when accessing a function on itertools that has been removed in Python 3.)z1Accessing a deprecated fields on the types modulezdeprecated-types-fieldzGUsed when accessing a field on types that has been removed in Python 3.)znext method definedznext-method-definedzyUsed when a next method is defined that would be an iterator in Python 2 but is treated as a normal function in Python 3.)z(dict.items referenced when not iteratingzdict-items-not-iteratingz_Used when dict.items is referenced in a non-iterating context (returns an iterator in Python 3))z'dict.keys referenced when not iteratingzdict-keys-not-iteratingz^Used when dict.keys is referenced in a non-iterating context (returns an iterator in Python 3))z)dict.values referenced when not iteratingzdict-values-not-iteratingz`Used when dict.values is referenced in a non-iterating context (returns an iterator in Python 3))z4Accessing a removed attribute on the operator modulezdeprecated-operator-functionzQUsed when accessing a field on operator module that has been removed in Python 3.)z2Accessing a removed attribute on the urllib modulezdeprecated-urllib-functionzXUsed when accessing a field on urllib module that has been removed or moved in Python 3.)z(Accessing a removed xreadlines attributezxreadlines-attributezTUsed when accessing the xreadlines() function on a file stream, removed in Python 3.)z/Accessing a removed attribute on the sys modulezdeprecated-sys-functionzLUsed when accessing a field on sys module that has been removed in Python 3.)z=Using an exception object that was bound by an except handlerzexception-escapez�Emitted when using an exception, that was bound in an except handler, outside of the except handler. On Python 3 these exceptions will be deleted once they get out of the except handler.)z6Using a variable that was bound inside a comprehensionzcomprehension-escapez�Emitted when using a variable, that was bound in a comprehension handler, outside of the comprehension itself. On Python 3 these variables will be deleted outside of the comprehension.)CZE1601ZE1602ZE1603ZE1604ZE1605ZE1609ZW1601ZW1602ZW1603ZW1604ZW1605ZW1606ZW1607ZW1608ZW1609ZW1610ZW1611ZW1612ZW1613ZW1614ZW1615ZW1616ZW1617ZW1618ZW1619ZW1620ZW1621ZW1622ZW1623ZW1624ZW1625ZW1626ZW1627ZW1628ZW1629ZW1630ZW1632ZW1633ZW1634ZW1635ZW1636ZW1637ZW1638ZW1639ZW1640ZW1641ZW1642ZW1643ZW1644ZW1645ZW1646ZW1647ZW1648ZW1649ZW1650ZW1651ZW1652ZW1653ZW1654ZW1655ZW1656ZW1657ZW1658ZW1659ZW1660ZW1661ZW1662Zapply�
basestring�buffer�cmpZcoerceZexecfile�file�input�intern�longZ	raw_input�reduce�round�
StandardError�unichr�unicode�xrange�reloadZ
__coerce__Z__delslice__Z__getslice__Z__setslice__Z__oct__Z__hex__�__nonzero__Z__cmp__Z__div__Z__idiv__Z__rdiv__�base64_codec�base64�base_64�	bz2_codec�bz2�	hex_codec�hex�quopri_codec�quopri�quotedprintable�quoted_printable�uu_codec�uu�
zlib_codec�zlib�zip�rot13�rot_13�sysZmaxintr:�izip�ifilter�imap�izip_longest�ifilterfalse�typesZEllipsisTypeZ
XRangeTypeZComplexTypeZ
StringTypeZTypeTypeZLongTypeZUnicodeTypeZ	ClassTypeZ
BufferTypeZStringTypesZNotImplementedTypeZNoneTypeZInstanceTypeZ	FloatTypeZ	SliceTypeZUnboundMethodTypeZ
ObjectTypeZIntTypeZ	TupleTypeZListTypeZDictType�FileTypeZDictionaryTypeZBooleanTypeZ
DictProxyType�anydbm�BaseHTTPServerr!�
CGIHTTPServer�ConfigParser�copy_reg�cPickle�	cStringIO�Cookie�	cookielib�dbhash�dumbdbmZdumbdb�Dialog�DocXMLRPCServer�
FileDialogZFixTk�gdbm�htmlentitydefs�
HTMLParser�httplib�
markupbase�Queue�repr�robotparser�ScrolledText�SimpleDialog�SimpleHTTPServer�SimpleXMLRPCServer�StringIO�dummy_thread�SocketServerztest.test_support�Tkinter�Tix�Tkconstants�tkColorChooser�tkCommonDialog�Tkdnd�tkFileDialog�tkFont�tkMessageBox�tkSimpleDialog�UserList�
UserString�whichdb�_winreg�	xmlrpclibZaudiodevZBastionZbsddb185Zbsddb3ZCanvasZcfmfileZcl�commands�compilerZdircache�dl�	exceptionZfpformatZhtmllibZihooksZimageopZimputilZ
linuxaudiodev�md5ZmhlibZ	mimetoolsZ
MimeWriterZmimifyZ	multifileZmutex�newZpopen2Z	posixfileZpureZrexecZrfc822ZsetsZshaZsgmllibZsreZ	stringoldZsunaudio�svztest.testall�threadZtimingZtoaiff�user�urllib2�urlparse�string�	maketrans�atof�atoiZatol�
capitalize�
expandtabs�find�rfind�index�rindex�count�lower�letters�split�rsplitZsplitfieldsr5Z
joinfields�lstrip�rstrip�strip�swapcase�	translate�upper�ljust�rjust�center�zfill�replaceZ	lowercaseZ	uppercaseZ
atol_errorZ
atof_errorZ
atoi_errorZindex_error�operatorZdiv�urllib�addbase�addclosehook�addinfo�
addinfourlZalways_safeZbasejoin�ftpcache�	ftperrors�
ftpwrapper�
getproxies�getproxies_environmentZgetproxies_macosx_sysconf�main�	noheaders�pathname2url�proxy_bypass�proxy_bypass_environmentZproxy_bypass_macosx_sysconf�quote�
quote_plus�
reporthook�	splitattr�	splithost�
splitnport�splitpasswd�	splitport�
splitquery�splittag�	splittype�	splituser�
splitvalue�unquote�unquote_plus�unwrap�url2pathname�
urlcleanup�	urlencode�urlopen�urlretrieveZ	exc_clear)zsys-max-intzdeprecated-itertools-functionzdeprecated-types-fieldzbad-python3-importzdeprecated-string-functionzdeprecated-operator-functionzdeprecated-urllib-functionzdeprecated-sys-function)rZ�)rZr�r�cCsg|]}t�|����qSr)rZextract_node�	repr_tree)�.0�xrrr�
<listcomp>yszPython3Checker.<listcomp>)zsys.version_info[0] == 2zsys.version_info[0] < 3zsys.version_info == (2, 7)zsys.version_info <= (2, 7)zsys.version_info < (3, 0)cs0d|_d|_t�|_g|_tt|�j||�dS)NF)�_future_division�_future_absolute_importr*�_modules_warned_about�
_branch_stack�superrT�__init__)�self�args�kwargs)�	__class__rrr�s
zPython3Checker.__init__cs2|s|jr|jdjs.tt|�j|f|�|�dS)N���)rrSrrT�add_message)rZmsg_id�always_warnrr)rrrr
�szPython3Checker.add_messagecCsdt|jtj�r>t|jjtj�r>|jjjdkr`|jjdkr`dSn"t|jtj�r`|j�	�|j
kr`dSdS)N�six�PY2TF)r�testrrB�exprr?r rCrMr��_python_2_tests)rr$rrr�_is_py2_test�szPython3Checker._is_py2_testcCs|j�t||�|���dS)N)r�appendrRr)rr$rrr�visit_if�szPython3Checker.visit_ifcCs|j��j|kst�dS)N)r�popr$�AssertionError)rr$rrr�leave_if�szPython3Checker.leave_ifcCs|j�t||�|���dS)N)rrrRr)rr$rrr�visit_ifexp�szPython3Checker.visit_ifexpcCs|j��j|kst�dS)N)rrr$r)rr$rrr�leave_ifexp�szPython3Checker.leave_ifexpcCsd|_d|_dS)z*Clear checker state after previous module.FN)r�r)rr$rrr�visit_module�szPython3Checker.visit_modulecCs�|��r�|j|jkrH|j}|j�d�r4|jdd�}|j|d|d�nD|jdkr�d}t�|tjdg�rnd	}t	|j
j
�|kr�|jd
|d�dS)N�__����z-method)r$�nextr;z
.staticmethodrznext-method-defined)Z	is_methodr �_unused_magic_methods�
startswithr
rZdecorated_withr�BUILTINSrLr)rr$�method_nameZfailing_arg_countrrr�visit_functiondef�s
z Python3Checker.visit_functiondefzparameter-unpackingcCs.x(|jD]}t|tj�r|jd|d�qWdS)Nzparameter-unpacking)r$)rrrrKr
)rr$�argrrr�visit_arguments�szPython3Checker.visit_argumentszcomprehension-escapecs�dd��jD���j��}|jtjtjd�}t��fdd�|jtjtjd�D��}|rZdSt	�}t
|�}xT|D]L}|j�ksn|j�jksn|j|ksn|���kr�qn|�
|j�|jd|d�qnWdS)NcSs"h|]}t|jtj�r|jj�qSr)r�targetr�
AssignNamer )r��	generatorrrr�	<setcomp>�sz0Python3Checker.visit_listcomp.<locals>.<setcomp>)�
skip_klassc3s(|] }|j�kr|j�jkr|VqdS)N)r �lineno)r��assign_name)�namesr$rr�	<genexpr>�sz0Python3Checker.visit_listcomp.<locals>.<genexpr>zcomprehension-escape)r$)�
generatorsr=rX�nodes_of_classrr?�FunctionDefr,r&r*r'r r*�addr
)rr$rX�scope_namesZhas_redefined_assign_nameZemitted_for_names�
scope_namer)r,r$r�visit_listcomp�s(




zPython3Checker.visit_listcompcCsh|�|j�\}}t|�sdS|j|jkr,dSt|�sDtt|�tj�rHdS|j�	�d}|j
||d�dS)z+Detect when a "bad" built-in is referenced.Nz-builtin)r$)r@r r%�
_bad_builtinsr	rr
rrPr�r
)rr$�
found_node�_�messagerrr�
visit_name�s
zPython3Checker.visit_namezprint-statementcCs|jd|dd�dS)Nzprint-statementT)r$r)r
)rr$rrr�visit_print�szPython3Checker.visit_printTcCsxxr|j��D]d\}}||kr||jkrt|t�rP|rp|j�|�|j||d�q|r||�|�r|j||d�qWdS)N)r$)�_bad_python3_module_mapr7rrr3r1r
�intersection)rr$�moduleZ
attributes�report_on_modulesr8Z
module_maprrr�_warn_if_deprecated�s
z"Python3Checker._warn_if_deprecatedcCs�|jdkr>x�|jD]&\}}|dkr*d|_q|dkrd|_qWnP|jsd|j�d�rd|jd|d�d|_t|�s�|js�|�	||jdd�|jD��|jd	d	d
kr�|j�d�r�t
|��tj
�s�|jd|d�dS)N�
__future__�divisionTrzno-absolute-import)r$cSsh|]}|d�qS)rr)r�r�rrrr(sz2Python3Checker.visit_importfrom.<locals>.<setcomp>r�*zimport-star-module-level)�modnamer,r�r�linter�is_message_enabledr
rQ�levelr?rrXr�Module)rr$r r7rrr�visit_importfroms 
zPython3Checker.visit_importfromcCsT|js&|j�d�r&|jd|d�d|_t|�sPx |jD]\}}|�||d�q6WdS)Nzno-absolute-import)r$T)rrDrEr
rQr,r?)rr$r r7rrr�visit_importszPython3Checker.visit_importzmetaclass-assignmentcCsXd|jkr|jd|d�t|j��dd�|��D��}d|krTd|krT|jd|d�dS)	NZ
__metaclass__zmetaclass-assignment)r$css|]}|jVqdS)N)r )r�r�rrrr-(sz0Python3Checker.visit_classdef.<locals>.<genexpr>�__eq__�__hash__zeq-without-hash)�localsr
r*�unionZ	mymethods)rr$Zlocals_and_methodsrrr�visit_classdef$s

zPython3Checker.visit_classdefzold-divisioncCsR|jsN|jdkrNx<|j|jfD]}t|tj�rt|jt�rPqW|j	d|d�dS)N�/zold-division)r$)
r��op�left�rightrr�Constr�floatr
)rr$r#rrr�visit_binop,s
zPython3Checker.visit_binopcCs�g}t|jtj�r`|jjdkr`t�|jj�}|s4dSd�t	j
�}t|tj�sX|��|kr�|j
}nLt|jtj�r�|jjdkr�t�|j�}|s�dSd�t	j
�}|��|kr�|j
}x,|p�gD] }|jdkr�|jd|d�dSq�WdS)N�sortz{}.listr)z	{}.sortedr]zusing-cmp-argument)r$)rr>rrBrCrrEr�formatrr rJrF�keywordsr?r r#r
)rr$rrNZ
builtins_listZbuiltins_sorted�kwargrrr�_check_cmp_argument5s&
z"Python3Checker._check_cmp_argumentcCs$t|tj�rt|jt�St|tj�S)N)rrrSr�strr?)r$rrr�_is_constant_string_or_nameOsz*Python3Checker._is_constant_string_or_namecCst|tj�o|jdkS)N)rrrSr)r$rrr�_is_noneUszPython3Checker._is_nonecCs t|j�|kot|j�o|jS)N)rLrr-rX)r$Znumber_of_argsrrr�_has_only_n_positional_argsYsz*Python3Checker._has_only_n_positional_argscCsJ|rtnt}x8|D]0}|tjkr&t}qt|tj�r>t|jt�sdSqW|S)N)rrr�UninferablerrSrr[)�inferred_types�
confidenceZ
inferred_typerrr�_could_be_string]s

zPython3Checker._could_be_stringc
Cs�|�|�t|jtj��r�t�}y�x�|jj��D]x}|tjkr@q0|�	|�t|tj
�rp|j||j|jj
hdd�t|�r0|jj
tkr0t|�s0d�|jj
�}|j||d�q0WWntjk
r�YnX|j�rr|�|�}|�rn|jj
dk�rt|j�dk�r|jd�r|jd}|�||�|jj
dk�rn|�|d	��rn|�|jd��rn|�|jd��rn|jd
||d�dS|j�r~dS|jj
dk�r�|jd
|d�n:|jj
dk�r�|jd|d�n|jj
dk�r�|jd|d�n�t|jtj��r�|j�|jj�d}t|��r�|jjdk�r:t|��s:d�|jj�}|j||d�|jjdk�r�|j�r�|j}x0|�p`gD]"}	|	jdk�rb|�|	j |�P�qbWdS)NF)r>zdict-{}-not-iterating)r$)�encode�decoder;rr�rzdeprecated-str-translate-call)r$rarznext-method-called)�iterkeys�
itervalues�	iteritemszdict-iter-method)�viewkeys�
viewvalues�	viewitemszdict-view-method)r/�map�rangeryz{}-builtin-not-iterating�open�encoding)!rZrr>rrBr*r�inferr_r1rGr?r rCr�DICT_METHODSrOrWr
�InferenceErrorrrbrL�_validate_encodingr^r]r\rXr?r@r%r#r)
rr$r`Zinferred_receiver�checkerZis_str_confidenceZ	first_argr6rrYrrr�
visit_calljsv






zPython3Checker.visit_callcCs.t|tj�r*|j}||jkr*|jd|d�dS)Nzinvalid-str-codec)r$)rrrSr�_invalid_encodingsr
)rrnr$rrrrrr�s
z!Python3Checker._validate_encodingcCsZy>x8|j��D]*}t|tj�s qt�|�r|jd|d�qWWntjk
rTdSXdS)z Look for indexing exceptions. zindexing-exception)r$N)	rrorrrr�inherit_from_std_exr
rq)rr$rNrrr�visit_subscript�s
zPython3Checker.visit_subscriptcCst|��tj�r|�|�dS)N)rZassign_typerZ	AugAssign�visit_attribute)rr$rrr�visit_assignattr�szPython3Checker.visit_assignattrcCs|�|�dS)N)rx)rr$rrr�
visit_delattr�szPython3Checker.visit_delattrzexception-message-attributezxreadlines-attributecCs�|jdkr|jd|d�dSd}yvxp|j��D]b}t|tj�rlt�|�rl|j|krl||j	kr^q.|jd|d�t|tj
�r.|j||j|jhdd�q.WWntj
k
r�dSXdS)	zLook for removed attributesZ
xreadlineszxreadlines-attribute)r$Nr8zexception-message-attributeF)r>)rCr
rrorrrrrvZinstance_attrsrGr?r rq)rr$Zexception_messagerNrrrrx�s"


zPython3Checker.visit_attributecs�dd��t�jtjtjf�r.|jd�d�dS�js8dS�j��}|jtj	tj
d�}t|�}��fdd�|D�}�fd	d
�|jtjtj
d�D�}x4|D],�t
��fdd�|D��r�q�|jd
�d�q�WdS)z@Visit an except handler block and check for exception unpacking.cSsF|��}|}x"|r.||kr.t|tj�s.|j}qWt|tj�oD|j|kS)N)rXrrrPr=�type)r$rX�currentrrr�_is_used_in_except_block�s
zDPython3Checker.visit_excepthandler.<locals>._is_used_in_except_blockzunpacking-in-except)r$N)r)cs2g|]*}|j�jjkr|j�jkr�|�s|�qSr)r r*)r�r3)r}r$rrr�sz6Python3Checker.visit_excepthandler.<locals>.<listcomp>cs h|]}|j�jjkr|j�qSr)r r*)r�r+)r$rrr(sz5Python3Checker.visit_excepthandler.<locals>.<setcomp>c3s*|]"}�j|ko�jknVqdS)N)r*)r��elem)�leaked_namer$rrr-sz5Python3Checker.visit_excepthandler.<locals>.<genexpr>zexception-escape)rr rrKrJr
r=rXr/r?r0r'r&r,)rr$rXr2Zpotential_leaked_namesZreassignments_for_same_namer)r}rr$r�visit_excepthandler�s(



z"Python3Checker.visit_excepthandlercCs|jd|d�dS)NrW)r$)r
)rr$rrr�
visit_repr szPython3Checker.visit_reprcCs^|jdkrdS|j}|�||�r$dSytt�|��}Wntjk
rLdSX|�||�dS)z[Visit a raise statement and check for raising
        strings or old-raise-syntax.
        N)�exc�_check_raise_valuerrZunpack_inferrq)rr$rrrrr�visit_raise$s
zPython3Checker.visit_raisecCs2t|tj�r.|j}t|t�r.|jd|d�dSdS)Nzraising-string)r$T)rrrSrr[r
)rr$rrrrrr�6s
z!Python3Checker._check_raise_value)F)T)8�__name__�
__module__�__qualname__rZIAstroidChecker�__implements__�enabledr r
ZNODE�msgsr3r5rrur;r|�version_inforrr
rrrrrrr"rZcheck_messagesr$r4r9r:r?rHrIrNrUrZ�staticmethodr\r]r^rbrtrrrwryrzrxr�r�r�r��
__classcell__rr)rrrT�s�




	

"


!
		
S0rTc@sdeZdZejZdZdZdddddifdd	d
ddgd�fd
ddddifdddddifd�Zdd�Z	dS)�Python3TokenCheckerrUFzUse of long suffixzlong-suffixz~Used when "l" or "L" is used to mark a long integer. This will not work in Python 3, since `int` and `long` types have merged.rY)rZrzUse of the <> operatorzold-ne-operatorz\Used when the deprecated "<>" operator is used instead of "!=". This is removed in Python 3.)ZW0331zold-ne-operator)rYrVzUse of old octal literalzold-octal-literalzrUsed when encountering the old octal syntax, removed in Python 3. To use the new syntax, prepend 0o on the number.z-Non-ascii bytes literals not supported in 3.xznon-ascii-bytes-literalzdUsed when non-ascii bytes literals are found in a program. They are no longer supported in Python 3.)ZE1606ZE1607ZE1608ZE1610cCs�x�t|�D]�\}\}}}}}|tjkrb|���d�rH|jd|dd�nt|�rb|jd|dd�||ddkr�|jd||d	dd�|tjkr
|�d
�r
t	dd�|D��r
|jd
|dd�q
WdS)N�lzlong-suffixr)�linezold-octal-literalr;z<>zold-ne-operatorr�bcss|]}t|�dkr|VqdS)�N)�ord)r�r~rrrr-psz5Python3TokenChecker.process_tokens.<locals>.<genexpr>znon-ascii-bytes-literal)
r.�tokenize�NUMBERr��endswithr
r�STRINGrr,)r�tokens�idx�tok_type�token�startr7rrr�process_tokenses
z"Python3TokenChecker.process_tokensN)
r�r�r�rZ
ITokenCheckerr�r r�r�r�rrrrr�?s(r�cCs |�t|��|�t|��dS)N)Zregister_checkerrTr�)rDrrr�registertsr�)+�__doc__r@rr�collectionsrrr|r��typingrrr�pylintrrZpylint.checkers.utilsr	r
Zpylint.interfacesrrZpylint.utilsr
Zpylint.checkersr�compilerrrr%rArDrGrprOrQrRZBaseCheckerrTZBaseTokenCheckerr�r�rrrr�<module>sj

9	"5