pylint-bot / pylint-unofficial

UNOFFICIAL playground for pylint github migration
0 stars 0 forks source link

Incorrect line numbers for C0103 #119

Open pylint-bot opened 10 years ago

pylint-bot commented 10 years ago

Originally reported by: Leon de Almeida (BitBucket: leondealmeida, GitHub: @leondealmeida?)


The error line is reported to be always one line after the last one of the decorator parameters with relevant data. The code below replicates it.

To validate the bug, add newlines below the 0 (last value on the decorators list). The test case is pretty much absurd - but more complex parameters (think the ones for pytest.mark.parametrize) may introduce lists and tuples that will also reproduce this behaviour (which is my original scenario).

#!python

"""
Some docstring

"""

def dummydecorator(aaa, bbb):
    """Some"""
    def real_decorator(fff):
        """pieces of"""
        def wrapper(*args, **kwargs):
            """docstring"""
            print aaa, bbb
            fff(*args, **kwargs)
        return wrapper
    return real_decorator

@dummydecorator(1, [
    0
# C0103 always points here - line 20

])
def a_very_very_very_long_function_name_to_make_it_sad():  # line 24
    """Docstring"""
    print 'LOL'

a_very_very_very_long_function_name_to_make_it_sad()

Pylint output (-rn option):

#!text

************* Module test_lint
C: 20, 0: Invalid function name "a_very_very_very_long_function_name_to_make_it_sad" (invalid-name)

pylint-bot commented 10 years ago

Original comment by Leon de Almeida (BitBucket: leondealmeida, GitHub: @leondealmeida?):


Added file with the test script

pylint-bot commented 10 years ago

Original comment by Sylvain Thénault (BitBucket: sthenault, GitHub: @sthenault?):


right, though this is very dependant to the underlying python parser provided by the interpreter.

pylint-bot commented 10 years ago

Original comment by Torsten Marek (BitBucket: tmarek, GitHub: @tmarek?):


Without a better AST implementation, it's not possible to determine on which line the function actually starts.

pylint-bot commented 10 years ago

Original comment by Sylvain Thénault (BitBucket: sthenault, GitHub: @sthenault?):


Removing version: 1.0 (automated comment)