pythonpylintmarshmallow

Exclude pylint too few public method error


In marshmallow you can use the custom Meta attribute to customize a schema's behavior:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

However, pylint complains that the Meta class has too few public methods and no class docstrings. I can always put a comment to disable these warnings locally but I'd like a global ignore for all Meta attributes which are classes because I have many throughout the codebase and putting comments everywhere is annoying. Is there global solution? I see a --exclude-too-few-public-methods argument for pylint but I tried it without success:

--exclude-too-few-public-methods='.*Meta'  # does not work
--exclude-too-few-public-methods='.*\.Meta' # does not work

Solution

  • Marshmallow has a default attribute class SchemaOpts which Meta can inherit from. Then, using --exclude-too-few-public-methods='.*SchemaOpts' works.