
    \hK                        S SK JrJrJr  S SKJrJrJrJrJ	r	  S SK
J
r
  S SKrS SKrS SKrS SKJr  S SKJr  S\0r\" \" \" \5      S    \\5      5      r\" \5      (       d   e\" \" \\5      5      r\" \S5      r\" \S	5      rS
rSrSrSrSrSrSrSrSr Sr!Sr"Sr#Sr$Sr%\RL                  " S5      r'\RL                  " S5      r(\RL                  " S5      r)\RL                  " S5      r*\RL                  " S5      r+\RL                  " S5      r,\RL                  " S5      r-\RL                  " S5      r.S  r/S! r0\1" 5       S"4S# jr2\1" 5       S4S$ jr3 " S% S&\Rh                  5      r5\5" 5       r6S' r7S( r8S) r9S* r:S+ r;S, r<S- r=S. r>S/ r?g)0    )walkseppardir)splitjoinabspathexistsisfile)globN)raises_test_this_file_encodingr   binexamplesz/File contains trailing whitespace: %s, line %s.z.File contains an implicit import: %s, line %s.z2File contains tabs instead of spaces: %s, line %s.z:File contains carriage returns at end of line: %s, line %sz+File contains string exception: %s, line %sz,File contains generic exception: %s, line %sz:File contains old-style raise statement: %s, line %s, "%s"z-File does not end with a newline: %s, line %sz/File ends with more than 1 newline: %s, line %sz6Function should start with 'test_' or '_': %s, line %sz.This is a duplicate test function: %s, line %sz3File contains assignments to self/cls: %s, line %s.z&File contains '.func is': %s, line %s.z+File contains bare expression: %s, line %s.z(^\s*(>>> )?(\.\.\. )?from .* import .*\*z9^\s*(>>> )?(\.\.\. )?raise(\s+(\'|\")|\s*(\(\s*)+(\'|\"))z=^\s*(>>> )?(\.\.\. )?raise(\s+Exception|\s*(\(\s*)+Exception)z1^\s*(>>> )?(\.\.\. )?raise((\s*\(\s*)|\s+)\w+\s*,z$^def\s+(?!(_|test))[^(]*\(\s*\)\s*:$z^def\s+test_.*:$z.*[/\\]test_.*\.py$z\.\s*func\s+isc                     [        U 5      [        U R                  5       5      -
  nXUS-    S;  a  U SU nO5XS-   S nU SU US[        U5      [        UR                  5       5      -
   -   nUR                  5       U:X  + $ )zwReturns True if there are tabs in the leading whitespace of a line,
including the whitespace of docstring code samples.   )z...z>>>N)lenlstrip
expandtabs)snchecksmores       ]/var/www/auris/envauris/lib/python3.13/site-packages/sympy/testing/tests/test_code_quality.pytab_in_leadingr   7   s     	AQXXZ Aq1u:'"1a%&	"1?s5zC,??@@  "e,,    c                   ^ [         R                  " U 5      R                   Vs/ s H&  n[        U[         R                  5      (       d  M$  UPM(     nn/ nU GH  nUR                   GH  n[        U[         R
                  5      (       d  M%  [        S UR                   5       5      (       a  MH  UR                  S:X  a  MZ  UR                  R                  (       d  Mw  UR                  R                  S   R                  m[         R                  " U5       H  n[        U[         R                  5      (       d  M$  UR                   H  n[        U[         R                  5      (       a#  UR                  T:X  a  UR!                  U5        ME  [        U[         R"                  5      (       d  Mf  [        U4S jUR$                   5       5      (       d  M  UR!                  U5        M     M     GM     GM     U$ s  snf )zReturns a list of "bad" assignments: if there are instances
of assigning to the first argument of the class method (except
for staticmethod's).
c              3      #    U  H5  n[        U[        R                  5      (       d  M$  UR                  S :H  v   M7     g7f)staticmethodN
isinstanceastNameid).0ds     r   	<genexpr>(find_self_assignments.<locals>.<genexpr>O   s0      I,q
1chh0G *144>),s   #??__new__r   c              3      >#    U  H5  n[        U[        R                  5      (       d  M$  UR                  T:H  v   M7     g 7fNr    )r%   q	first_args     r   r'   r(   ^   s/      ">V%/388%< #4!$$)"3Vs
   #A A )r"   parsebodyr!   ClassDefFunctionDefanydecorator_listnameargsargr   Assigntargetsr#   r$   appendTupleelts)r   r   tbadcmar-   s          @r   find_self_assignmentsrA   C   s`   
 IIaL%%E%qAs||)D%AE
CAa11 I,,I I Ivv"66;;A**IXXa[a,,YY%a22qtty7HJJqM(CII66! ">QVV "> > >JJqM ' !  . J5 	Fs   #G8G8z*.pyc           	      z    U (       d  g[        U 5       H$  u  pEn[        [        [        XC5      5      X5        M&     g)z
Checks all files in the directory tree (with base_path as starting point)
with the file_check function provided, skipping files that contain
any of the strings in the set provided by exclusions.
N)r   check_filesr   r   )	base_path
file_check
exclusionspatternrootdirsfiless          r   check_directory_treerK   e   s1     !)_EDd,-zF -r   c                    ^ U (       d  gU  Hj  m[        T5      (       a  [        T5      (       d  M%  [        U4S jU 5       5      (       a  MA  Ub  [        R                  " UT5      (       d  Mb  U" T5        Ml     g)z
Checks all files with the file_check function provided, skipping files
that contain any of the strings in the set provided by exclusions.
Nc              3   ,   >#    U  H	  oT;   v   M     g 7fr+    )r%   exfnames     r   r'   check_files.<locals>.<genexpr>{   s     0ZrU{Zs   )r	   r
   r2   rematch)rJ   rE   rF   rG   rP   s       @r   rC   rC   q   sZ    
 e}}F5MM0Z000?bhhw66u r   c                   $    \ rS rSrSrS rS rSrg)_Visit   a=  return the line number corresponding to the
line on which a bare expression appears if it is a binary op
or a comparison that is not in a with block.

EXAMPLES
========

>>> import ast
>>> class _Visit(ast.NodeVisitor):
...     def visit_Expr(self, node):
...         if isinstance(node.value, (ast.BinOp, ast.Compare)):
...             print(node.lineno)
...     def visit_With(self, node):
...         pass  # no checking there
...
>>> code='''x = 1    # line 1
... for i in range(3):
...     x == 2       # <-- 3
... if x == 2:
...     x == 3       # <-- 5
...     x + 1        # <-- 6
...     x = 1
...     if x == 1:
...         print(1)
... while x != 1:
...     x == 1       # <-- 11
... with raises(TypeError):
...     c == 1
...     raise TypeError
... assert x == 1
... '''
>>> _Visit().visit(ast.parse(code))
3
5
6
11
c                     [        UR                  [        R                  [        R                  45      (       a   [
        SUR                  4-  5       eg )N )r!   valuer"   BinOpComparemessage_bare_exprlinenoselfnodes     r   
visit_Expr_Visit.visit_Expr   s>    djj399ckk":;;>*b$++->>>4 <r   c                     g r+   rN   r^   s     r   
visit_With_Visit.visit_With   s    r   rN   N)__name__
__module____qualname____firstlineno____doc__ra   rd   __static_attributes__rN   r   r   rU   rU      s    $J?r   rU   c                    [         R                  " U 5      n [        R                  U5        g! [         a  nUR
                  (       d   eUR
                  S   nUR                  [        R                  SS5      S   5      (       d   e[        UR                  SS5      S   R                  S5      5      s SnA$ SnAff = f)zUreturn None or else 0-based line number of code on which
a bare expression appeared.
r   :    .N)r"   r.   BareExprvisitAssertionErrorr5   
startswithr\   r   intrsplitrstrip)codetreemsgs      r   line_with_bare_exprr{      s     99T?D6t 6xxxhhqk~~/55c1=a@AAAA3::c1%a(//455	6s   . 
C A=B;5C ;C c                  p  ^^ U4S jn U4S jmS Vs/ s H  n[        [        U5      PM     nnS[        -  S[        -  S[        -  S[        -  S[        -  1nS	[        -  S
[        -  S[        -  S[        -  S[        -  S[        -  S[        -  S[        -  S[        -  S[        -  S[        -  S[        -  S[        -  S[        -  S[        -  S[        -  S[        -  S[        -  S[        -  1m[        X 5        [	        [
        U 1 SkS5        [	        [        X5        [	        [        X5        gs  snf )aL  
This test tests all files in SymPy and checks that:
  o no lines contains a trailing whitespace
  o no lines end with 

  o no line uses tabs instead of spaces
  o that the file ends with a single newline
  o there are no general or string exceptions
  o there are no old style raise statements
  o name of arg-less test suite functions start with _ or test_
  o no duplicate function names that start with test_
  o no assignments to self variable in class methods
  o no lines contain ".func is" except in the test suite
  o there is no do-nothing expression like `a == b` or `x + 1`
c                    > [        U SS9 nT" X5        S S S 5        [        U SS9 n[        X5        S S S 5        g ! , (       d  f       N-= f! , (       d  f       g = f)Nutf8)encoding)openr   )rP   	test_filetest_this_files     r   testtest_files.<locals>.test   sH    %&)Y5, *%&)Y$U6 *) *)))s   	<A
A

Ac                   >^  S nUR                  5       nUR                  S5        [        T ;  a  T OT R                  [        S5      S   nUR	                  S5      (       a  [        U5      nUb   [        T US-   4-  5       eS nSn[        5       n[        U5       GH^  u  p%[        R                  T 5      (       a  [        R                  U5      (       a   [        T US-   4-  5       e[        R                  U5      (       a[  US-  nUR                  USS  R                  S5      S   R!                  5       5        [#        U5      U:w  a   [$        T US-   4-  5       eUR'                  S5      (       a   [(        T US-   4-  5       eUR'                  S5      (       a   [*        T US-   4-  5       e[-        U5      (       a   [.        T US-   4-  5       e[0        R3                  U5      (       a   [4        T US-   4-  5       e[6        R3                  U5      (       a   [8        T US-   4-  5       e[:        R3                  U5      (       a1  [=        [?        U 4S	 jT	5      5      (       d   [@        T US-   4-  5       e[B        R3                  U5      (       a-  [        R3                  T 5      (       d   [D        T US-   4-  5       e[F        R3                  U5      nUc  GM>   [H        T US-   URK                  S
5      4-  5       e   UbI  US:X  a  US:  a   [L        T US-   4-  5       eUR'                  S5      (       d   [N        T US-   4-  5       eg g )Nr   rn   test_r   ()z 
z	
z
c                    > U T;   $ r+   rN   )rO   rP   s    r   <lambda>4test_files.<locals>.test_this_file.<locals>.<lambda>   s	    rU{r      
)(readseekr   rv   rt   r{   r\   set	enumeratetest_file_rerS   test_suite_def_remessage_test_suite_deftest_ok_def_readdr   stripr   message_duplicate_testendswithmessage_spacemessage_carriager   message_tabsstr_raise_researchmessage_str_raisegen_raise_remessage_gen_raiseimplicit_test_relistfiltermessage_implicit
func_is_remessage_func_isold_raise_remessage_old_raisegroupmessage_multi_eofmessage_eof)
rP   r   idxrx   pylineteststest_setresultimport_excludes
   `        r   r   "test_files.<locals>.test_this_file   s   ~~q&UELLa,@,D==!!%d+C?>+ucAg.>>>55"9-IC!!%(($**400K"8E37;K"KK5!''--QJELLab!4Q!7!=!=!?@8}-O&<sQw?O&OOu}}_-->mucAg.>>>u}}V$$A.%q1AAAud##=leS1W-===u""4((B/5#'2BBBu""4((B/5#'2BBBu ''--V$:NKLLA.%q1AAAu  &&|/B/B5/I/I@oa0@@@u!((.F!5/37FLLO35 5 5u9 .> t|aB/5#'2BBBu]]4((<kUC!G,<<<u ) r   )z	isympy.pyzbuild.pyzsetup.pyzL%(sep)ssympy%(sep)sparsing%(sep)sautolev%(sep)s_antlr%(sep)sautolevparser.pyzK%(sep)ssympy%(sep)sparsing%(sep)sautolev%(sep)s_antlr%(sep)sautolevlexer.pyzN%(sep)ssympy%(sep)sparsing%(sep)sautolev%(sep)s_antlr%(sep)sautolevlistener.pyzH%(sep)ssympy%(sep)sparsing%(sep)slatex%(sep)s_antlr%(sep)slatexparser.pyzG%(sep)ssympy%(sep)sparsing%(sep)slatex%(sep)s_antlr%(sep)slatexlexer.pyz%(sep)ssympy%(sep)s__init__.pyz%(sep)svector%(sep)s__init__.pyz"%(sep)smechanics%(sep)s__init__.pyz %(sep)squantum%(sep)s__init__.pyz%(sep)spolys%(sep)s__init__.pyz,%(sep)spolys%(sep)sdomains%(sep)s__init__.pyz#%(sep)sinteractive%(sep)ssession.pyz%(sep)sisympy.pyz%(sep)sbin%(sep)ssympy_time.pyz$%(sep)sbin%(sep)ssympy_time_cache.pyz&%(sep)sparsing%(sep)ssympy_tokenize.pyz'%(sep)splotting%(sep)spygletplot%(sep)sz)%(sep)sbin%(sep)stest_external_imports.pyz*%(sep)sbin%(sep)stest_submodule_imports.pyz"%(sep)sutilities%(sep)sruntests.pyz %(sep)sutilities%(sep)spytest.pyz"%(sep)sutilities%(sep)srandtest.pyz"%(sep)sutilities%(sep)stmpfiles.pyz)%(sep)sutilities%(sep)squality_unicode.py>   ~.sh.pyc*N)r   TOP_PATHsepdrC   rK   BIN_PATH
SYMPY_PATHEXAMPLES_PATH)r   filetop_level_filesexcluder   r   s       @@r   
test_filesr      sB    71=j9  9tHd+ 9O  	WY]]UX\\X[__RUYYQTXXG 	)4/ 	*D0,t3*T1(4/6=-4T!(4/.50471D83d:4t;,t3*T1,t3,t33d:;N> &4)=sCT36as   D3c                 <    [         R                  " SS5      S-  U -   $ )Nr   
   ro   )randomrandint)r>   s    r   _with_spacer   =  s    >>!R $q((r   c                  4   / SQn / SQn/ SQn/ SQnU  Hu  n[         R                  [        U5      5      b   U5       e[        R                  [        U5      5      b   U5       e[        R                  [        U5      5      c  Mp   U5       e   U H)  n[         R                  [        U5      5      b  M$   U5       e   U H)  n[        R                  [        U5      5      b  M$   U5       e   U H)  n[        R                  [        U5      5      b  M$   U5       e   g )N)z#some text # raise Exception, 'text'z2raise ValueError('text') # raise Exception, 'text'raise ValueError('text')zraise ValueErrorr   zraise ValueError('text') #,zB'"""This function will raise ValueError, except when it doesn't"""zraise (ValueError('text'))zraise 'exception'zraise 'Exception'zraise "exception"zraise "Exception"zraise 'ValueError')z1raise Exception('text') # raise Exception, 'text'raise Exception('text')zraise Exceptionr   zraise Exception('text') #,raise Exception, 'text'1raise Exception, 'text' # raise Exception('text')1raise Exception, 'text' # raise Exception, 'text'>>> raise Exception, 'text'5>>> raise Exception, 'text' # raise Exception('text')5>>> raise Exception, 'text' # raise Exception, 'text')r   r   r   r   r   r   zraise ValueError, 'text'z2raise ValueError, 'text' # raise Exception('text')z2raise ValueError, 'text' # raise Exception, 'text'z>>> raise ValueError, 'text'z6>>> raise ValueError, 'text' # raise Exception('text')z6>>> raise ValueError, 'text' # raise Exception, 'text'zraise(ValueError,zraise (ValueError,zraise( ValueError,zraise ( ValueError,zraise(ValueError ,zraise (ValueError ,zraise( ValueError ,zraise ( ValueError ,)r   r   r   r   r   )candidates_okstr_candidates_failgen_candidates_failold_candidates_failr>   s        r   'test_raise_statement_regular_expressionr   B  s   
M. "";q>2:=A=:"";q>2:=A=:"";q>2:=A=:  !"";q>2>AA> ! "";q>2>AA> ! "";q>2>AA> !r   c                      / SQn / SQnU  H)  n[         R                  [        U5      5      c  M$   U5       e   U H)  n[         R                  [        U5      5      b  M$   U5       e   g )N)zfrom sympy import somethingz>>> from sympy import somethingz%from sympy.somewhere import somethingz)>>> from sympy.somewhere import somethingzimport sympyz>>> import sympyz import sympy.something.somethingz... import sympyz$... import sympy.something.somethingz... from sympy import somethingz)... from sympy.somewhere import somethingz>> from sympy import *z# from sympy import *zsome text # from sympy import *)zfrom sympy import *z>>> from sympy import *zfrom sympy.somewhere import *z!>>> from sympy.somewhere import *z... from sympy import *z!... from sympy.somewhere import *)r   r   r   r   candidates_failr>   s      r   (test_implicit_imports_regular_expressionr     sf    M O &&{1~6>AA> &&{1~6BEAEB r   c                      / SQn / SQnU  H   n[         R                  U5      c  M   U5       e   U H   n[         R                  U5      b  M   U5       e   g )N)z    def foo():
zdef foo(arg):
zdef _foo():
zdef test_foo():
)zdef foo():
zdef foo() :
zdef foo( ):
zdef  foo():
)r   r   r   s      r   test_test_suite_defsr     s^    MO  ''*25A52  ''*6996 r   c                  z    / SQn SS/nSnS nU  H  nU" U5      U:X  a  M   e   U H  nU" U5      U:w  a  M   e   g )N)zdef foo():
def foo():
zdef test():
def test_():
zdef test_():
def test__():
zdef test_():
def test_ ():
zdef test_1():
def  test_1():
Nr   c                 L   Sn[        5       n[        U R                  5       5       H{  u  p4[        R	                  U5      (       d  M!  US-  nUR                  USS  R                  S5      S   R                  5       5        [        U5      U:w  d  Mk  S[        SUS-   4-  4s  $    g)Nr   rn   r   r   Fr   r   )
r   r   
splitlinesr   rS   r   r   r   r   r   )r   r   r   r   r   s        r   r   'test_test_duplicate_defs.<locals>.check  s    5"4??#45IC##D))
T!"X^^C0399;<x=E) "8GS1W;M"MMM 6 r   rN   )r   r   okr   r>   s        r   test_test_duplicate_defsr     sZ    M 	()O 
B	 Qx2~~ Qx2~~ r   c                  |    / SQn / SQnU  H  n[        U5      / :X  a  M   e   U H  n[        U5      / :w  a  M   e   g )N)z4class A(object):
    def foo(self, arg): arg = self
z9class A(object):
    def foo(self, arg): self.prop = arg
z?class A(object):
    def foo(self, arg): obj, obj2 = arg, self
zCclass A(object):
    @classmethod
    def bar(cls, arg): arg = cls
z2class A(object):
    def foo(var, arg): arg = var
)z4class A(object):
    def foo(self, arg): self = arg
z>class A(object):
    def foo(self, arg): obj, self = arg, arg
zCclass A(object):
    def foo(self, arg):
        if arg: self = argzCclass A(object):
    @classmethod
    def foo(cls, arg): cls = arg
z2class A(object):
    def foo(var, arg): var = arg
)rA   r   s      r   test_find_self_assignmentsr     sL    MO $Q'2--- $Q'2--- r   c                     ^ ^^^ S/mS/mSm S/m[        [        U UUU4S j5        Sm S/m[        T TTT5        Sm S/m[        [        U UUU4S j5        Sm S/m[        T TTT5        g )Nfoobarabcu   αc                      > [        T TTT5      $ r+   r   rP   r   unicode_strict_whitelistunicode_whitelists   r   r   ,test_test_unicode_encoding.<locals>.<lambda>      #;y+-E$Gr   c                      > [        T TTT5      $ r+   r   r   s   r   r   r     r   r   )r   rs   r   r   s   @@@@r   test_test_unicode_encodingr     s     %wEI
> G H EIy+-EG EI
> G H EIy+-EGr   )@osr   r   r   os.pathr   r   r   r	   r
   r   rR   r   r"   sympy.testing.pytestr   sympy.testing.quality_unicoder   r   __file__r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   message_self_assignmentsr   r\   compiler   r   r   r   r   r   r   r   r   rA   r   rK   rC   NodeVisitorrU   rq   r{   r   r   r   r   r   r   r   r   rN   r   r   <module>r      s       8 8  	  
 ' B 	s| T%/!,ff=>
j 4
F+,% Xz* BC CO A B R =E Q I P :A ::IJ zz@BzzDFzzNOJJFG /0zz01ZZ)*
	-D <?5& 	G /2eT  *S__ *Z 86{7|)
@BFF>:&6.,Gr   