Menu

#375 Keyword arguments are interpreted as variables (python)

open
nobody
python (3)
5
2017-09-11
2017-09-10
No

Kwargs to functions or constructors are interpreted as variables, which greatly polluted the output with bogus data.

Here's a very brief example to quickly reproduce the issue:

from datetime import datetime


class A:
    when = datetime(
        year=2017,
        month=9,
        day=10,
    )


a = float(
    x=99,
)

Output:

!_TAG_FILE_FORMAT       2       /extended format; --format=1 will not append ;" to lines/      
!_TAG_FILE_SORTED       1       /0=unsorted, 1=sorted, 2=foldcase/                             
!_TAG_PROGRAM_AUTHOR    Darren Hiebert  /dhiebert@users.sourceforge.net/                       
!_TAG_PROGRAM_NAME      Exuberant Ctags //     
!_TAG_PROGRAM_URL       http://ctags.sourceforge.net    /official site/                        
!_TAG_PROGRAM_VERSION   5.8     //             
A       test.py /^class A:$/;"  c              
a       test.py /^a = float($/;"        v      
datetime        test.py /^from datetime import datetime$/;"     i                              
day     test.py /^        day=10,$/;"   v       class:A                                        
month   test.py /^        month=9,$/;"  v       class:A                                        
when    test.py /^    when = datetime($/;"      v       class:A                                
x       test.py /^    x=99,$/;" v              
year    test.py /^        year=2017,$/;"        v       class:A    

Discussion

  • Masatake YAMATO

    Masatake YAMATO - 2017-09-11

    Universal-ctags(https://ctags.io) forked from Exuberant-ctags works well.

    [yamato@master]/tmp% cat /tmp/foo.py
    cat /tmp/foo.py
    from datetime import datetime
    
    class A:
        when = datetime(
            year=2017,
            month=9,
            day=10,
        )
    
    a = float(
        x=99,
    )
    [yamato@master]/tmp% u-ctags -o - /tmp/foo.py 
    u-ctags -o - /tmp/foo.py 
    A   /tmp/foo.py /^class A:$/;"  c
    a   /tmp/foo.py /^a = float($/;"    v
    when    /tmp/foo.py /^    when = datetime($/;"  v   class:A
    
     
  • Hugo Osvaldo Barrera

    Universal-ctags still doesn't have any stable releases yet, regrettably.

     

Log in to post a comment.

MongoDB Logo MongoDB