@_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.
@_MetricWrapperchanges 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-parameterto 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:
client_python/prometheus_client/core.py
Line 544 in d858f0d
Histogram
__init__():client_python/prometheus_client/core.py
Line 847 in d858f0d
The linter complains that
labelvaluesisn't being set because it thinks the two positional arguments I pass arenameandlabelnames, when in fact I'm passingnameanddocumentation.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.