Skip to content

@_MetricWrapper breaks pylint argument checks #210

@ghost

Description

@_MetricWrapper changes the call signature of the classes it wraps, breaking pylint argument checks. This causes us to have to annotate every single prometheus object with # pylint: disable-msg=no-value-for-parameter to avoid erroneous lint warnings. This gets rather silly.

If the mandatory arguments in the call signature of the wrapper and the metrics classes (like Histogram, Counter, etc) matched, pylint would no longer raise this warning.

Code pointers:
Wrapper:

def init(name, documentation, labelnames=(), namespace='', subsystem='', registry=REGISTRY, **kwargs):

Histogram __init__():
def __init__(self, name, labelnames, labelvalues, buckets=(.005, .01, .025, .05, .075, .1, .25, .5, .75, 1.0, 2.5, 5.0, 7.5, 10.0, _INF)):

The linter complains that labelvalues isn't being set because it thinks the two positional arguments I pass are name and labelnames, when in fact I'm passing name and documentation.

Note that this is not a bug with PyLint, which can only be expected to do static analysis. Because decorators are arbitrary Python code, PyLint would have to execute the decorator in order to find the wrapper arguments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions