Skip to content

kwargs used by decorator being flagged as unused. #3662

Open
@rtaft

Description

@rtaft

After upgrading from pylint 2.4.4 to 2.5.2, we started getting unused-argument errors with kwargs that are sent to decorators for Marshmallow. What is weird is that it is not consistent. In my codebase, I encountered these and added this to the disabled list where I was seeing the lint error to ignore it. However there are many other places in the codebase that we use Marshmallow decorators that did not error for me, and other developers are seeing errors on some (but not all) of those.

Steps to reproduce

  1. Create and lint a Marshmallow Schema that utilizes decorators like validates_schema
from marshmallow import fields, Schema, validate, validates_schema, ValidationError

class TestSchema(Schema):
    test_url = fields.Str(required=True, validate=validate.Length(max=1000))

    @validates_schema
    def validate_test_url(self, data, **kwargs):
        if data['test_url'] and not data['test_url'].startswith('https://test.example.com'):
            raise ValidationError('URL must start with {}'.format('https://test.example.com'))

Current behavior

[W0613(unused-argument), TestSchema.validate_test_url] Unused argument 'kwargs'

Expected behavior

Passes without error

pylint --version output

pylint 1.9.5,
astroid 1.6.6
Python 2.7.17 (default, Apr 15 2020, 17:20:14)
[GCC 7.5.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions