Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False Negative: Decorator signatures are unverified #1225

Closed
deckar01 opened this issue Dec 16, 2016 · 3 comments
Closed

False Negative: Decorator signatures are unverified #1225

deckar01 opened this issue Dec 16, 2016 · 3 comments

Comments

@deckar01
Copy link

Steps to reproduce

def decorator(func):
    def wrap():
        return func('test')
    return wrap

@decorator
def simple():
    return 'test'

simple()

Current behavior

Pylint does not detect any errors.

Expected behavior

Pylint should detect that func is called with too many arguments.

pylint --version output

No config file found, using default configuration
pylint 1.6.4, 
astroid 1.4.8
Python 2.7.12 (default, Jun 28 2016, 06:57:42) [GCC]

Related issues

#259

@PCManticore
Copy link
Contributor

Closing as duplicate.

@deckar01
Copy link
Author

deckar01 commented Dec 21, 2016

@PCManticore I took a closer look at it, and this is not actually checked with function composition either, so it is less related to #259 than I thought.

def dec(func):
    def wrap():
        return func('test')
    return wrap

def simple():
    return 'test'

hard = dec(simple)

hard()

Boiling it down further illustrates the difference.

def call(func):
    return func('test')

def simple():
    return 'test'

call(simple)

This code is guaranteed to error, but pylint doesn't report any errors.

@PCManticore
Copy link
Contributor

This looks like an example of pylint-dev/astroid#177. This, combined with lack of flow control understanding across the inference, plus lack of understanding decorators, that stem from the first two points, results in the problems you are noticing. We know about it, it's not trivial to fix, but it's on our roadmap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants