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

@classmethod vs @builtins.classmethod discrepancy #3417

Closed
steve-thousand opened this issue Feb 20, 2020 · 0 comments · Fixed by pylint-dev/astroid#759
Closed

@classmethod vs @builtins.classmethod discrepancy #3417

steve-thousand opened this issue Feb 20, 2020 · 0 comments · Fixed by pylint-dev/astroid#759

Comments

@steve-thousand
Copy link

steve-thousand commented Feb 20, 2020

I am using pylint on a script that uses the AWS CDK. In their source, they use a fully qualified @builtins.classmethod vs @classmethod to mark a class method and I am getting a no-value-for-parameter because pylint is expecting a parameter for the cls param. I am able to recreate it like so:

import pylint
import builtins

class Foo():
    @classmethod
    def bar1(cls, text):
        print(text)

    @builtins.classmethod
    def bar2(cls, text):
        print(text)

print(pylint.__version__)
Foo.bar1("apple")
Foo.bar2("pear")

This runs on python 3.7.3 and the output is:

2.4.4
apple
pear

I am looking at this line of the class checker file where BUILTIN_DECORATORS = {"builtins.property", "builtins.classmethod"} is defined but then never used.

Current behavior

pylint warns of No value for argument 'text' in unbound method call pylint(no-value-for-parameter) when calling bar2 with only one parameter.

pylint also warns of a problem at the definition of bar2: Method should have "self" as first argument pylint(no-self-argument)

Expected behavior

Both methods should be interpreted as valid class methods and usage without passing a parameter for cls should not be interpreted as invalid usage

pylint --version output

2.4.4

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

Successfully merging a pull request may close this issue.

1 participant