관리-도구
편집 파일: test_undefined_names.cpython-311.pyc
� �܋f \ � �f � d dl Z d dlmZmZ d dlmZmZ G d� de� � Z G d� de� � Z dS )� N)�messages�checker)�TestCase�skipc �" � e Zd Zd� Zd� Zd� Zd� Zd� Z ed� � d� � � Z d� Z d � Zd � Zd� Z ed� � d� � � Z ed� � d � � � Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Z ed� � d � � � Z!d!� Z"d"� Z#d#� Z$d$� Z%d%� Z&d&� Z'd'� Z(d(� Z)d)� Z*d*� Z+d+� Z,d,� Z-d-� Z.d.� Z/d/� Z0d0� Z1d1� Z2d2� Z3d3� Z4d4� Z5d5� Z6d6� Z7d7� Z8d8� Z9d9� Z:d:� Z;d;� Z<d<� Z=d=� Z>d>� Z?d?� Z@d@� ZAdA� ZBdB� ZCdC� ZDdD� ZEdES )F�Testc �F � | � dt j � � d S )N�bar��flakes�m� UndefinedName��selfs �s/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/pyflakes/test/test_undefined_names.py�test_undefinedzTest.test_undefined s � ����E�1�?�+�+�+�+�+� c �0 � | � d� � d S )Nz[a for a in range(10) if a]�r r s r �test_definedInListCompzTest.test_definedInListComp s � ����1�2�2�2�2�2r c �F � | � dt j � � d S )Nz2 [a for a in range(10)] a r r s r �test_undefinedInListCompzTest.test_undefinedInListComp s. � ���� � �O� %� %� %� %� %r c �\ � | � dt j t j � � dS )zxException names can't be used after the except: block. The exc variable is unused inside the exception handler.zx try: raise ValueError('ve') except ValueError as exc: pass exc N�r r r �UnusedVariabler s r �test_undefinedExceptionNamez Test.test_undefinedExceptionName s5 � � ��� � �_�a�.� 0� 0� 0� 0� 0r c �0 � | � d� � dS )z�Locals declared in except: blocks can be used after the block. This shows the example in test_undefinedExceptionName is different.zy try: raise ValueError('ve') except ValueError as exc: e = exc e Nr r s r � test_namesDeclaredInExceptBlocksz%Test.test_namesDeclaredInExceptBlocks! �) � � ��� � � � � � r z5error reporting disabled due to false positives belowc �F � | � dt j � � dS )z�Exception names obscure locals, can't be used after. Last line will raise UnboundLocalError on Python 3 after exiting the except: block. Note next two examples for false positives to watch out for.z� exc = 'Original value' try: raise ValueError('ve') except ValueError as exc: pass exc Nr r s r �1test_undefinedExceptionNameObscuringLocalVariablez6Test.test_undefinedExceptionNameObscuringLocalVariable. s0 � � ��� � �O� %� %� %� %� %r c �\ � | � dt j t j � � dS )z�Exception names are unbound after the `except:` block. Last line will raise UnboundLocalError. The exc variable is unused inside the exception handler. z� try: raise ValueError('ve') except ValueError as exc: pass print(exc) exc = 'Original value' Nr r s r �2test_undefinedExceptionNameObscuringLocalVariable2z7Test.test_undefinedExceptionNameObscuringLocalVariable2? s5 � � ��� � �_�a�.� 0� 0� 0� 0� 0r c �F � | � dt j � � dS )z�Exception names obscure locals, can't be used after. Unless. Last line will never raise UnboundLocalError because it's only entered if no exception was raised.z� exc = 'Original value' try: raise ValueError('ve') except ValueError as exc: print('exception logged') raise exc N�r r r r s r �?test_undefinedExceptionNameObscuringLocalVariableFalsePositive1zDTest.test_undefinedExceptionNameObscuringLocalVariableFalsePositive1N �1 � � ��� � � � � � � � r c �0 � | � d� � dS )z7The exception name can be deleted in the except: block.z\ try: pass except Exception as exc: del exc Nr r s r �test_delExceptionInExceptzTest.test_delExceptionInExcept] �'