Skip to content

@classmethod vs @builtins.classmethod discrepancy #3417

@steve-thousand

Description

@steve-thousand

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions