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

assignment-from-no-return considers the wrong method if ambiguous #1683

Open
cschramm opened this issue Jul 23, 2018 · 2 comments
Open

assignment-from-no-return considers the wrong method if ambiguous #1683

cschramm opened this issue Jul 23, 2018 · 2 comments
Labels

Comments

@cschramm
Copy link

cschramm commented Jul 23, 2018

Steps to reproduce

class Test():
    def test(self):
        pass

    def test(self):
        return True

A = Test().test()

Current behavior

5:4: E0102: method already defined line 2 (function-redefined)
5:4: R0201: Method could be a function (no-self-use)
8:0: E1111: Assigning to function call which doesn't return (assignment-from-no-return)

Expected behavior

5:4: E0102: method already defined line 2 (function-redefined)
5:4: R0201: Method could be a function (no-self-use)

pylint --version output

pylint 2.0.1
astroid 2.0.1
Python 3.6.5 (default, May 11 2018, 13:30:17) 
[GCC 7.3.0]

pylint-dev/pylint@9a9de85 adds that check for methods and 2aa27e9 causes the first of the definitions to be the only one that gets returned from infer_attribute. ❎

For ambiguous local functions, infer_name returns the correct definition. ✔️
For ambiguous module functions, infer_attribute returns all definitions and safe_infer detects that ambiguity so that none of them get actually checked. ❎ (I'd consider that an issue as well but it only causes false negatives, so it's not a huge one).

@brycepg
Copy link
Contributor

brycepg commented Jul 24, 2018

Thanks for the report

I think I'll make the first result of ClassDef.getattr be the last defined name in a classdef

@samertm
Copy link

samertm commented Sep 27, 2018

FWIW, we've also hit this issue.

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

No branches or pull requests

5 participants