Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typing to Histogram/Summary/Gauge #759

Merged
merged 4 commits into from
Feb 1, 2022

Conversation

Pliner
Copy link
Contributor

@Pliner Pliner commented Jan 28, 2022

Hi,

It is a small addition to Histogram/Summary/Gauge typings.

PS I suppose at the current stage it is fine to set disallow_incomplete_defs to True.

Also we could set disallow_incomplete_defs to True

Signed-off-by: Yury Pliner <yury.pliner@gmail.com>
@Pliner Pliner force-pushed the add-typing-to-histogram branch from 3c515e7 to a34a80f Compare January 28, 2022 16:54
@@ -413,7 +413,7 @@ def set_function(self, f):

self._raise_if_not_observable()

def samples(self) -> Iterable[Sample]:
def samples(_: Gauge) -> Iterable[Sample]:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the only one thing which is needed to enable disallow_incomplete_defs.

Signed-off-by: Yury Pliner <yury.pliner@gmail.com>
@Pliner Pliner force-pushed the add-typing-to-histogram branch from 6b21fbd to 76c0c48 Compare January 28, 2022 17:17
@Pliner Pliner changed the title Add typing to Histogram Add typing to Histogram/Summary/Gauge Jan 28, 2022
return (Sample('', {}, float(f()), None, None),)

self._child_samples = types.MethodType(samples, self)
self._child_samples = types.MethodType(samples, self) # type: ignore
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mypy is not fond of such an overwrite of a method

@Pliner
Copy link
Contributor Author

Pliner commented Jan 28, 2022

@csmarchbanks Could you look on it please? Many thanks.

Copy link
Member

@csmarchbanks csmarchbanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is great!

I will take a closer look next week, but generally this is looking good to me.

prometheus_client/metrics.py Outdated Show resolved Hide resolved
Signed-off-by: Yury Pliner <yury.pliner@gmail.com>
Copy link
Member

@csmarchbanks csmarchbanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small comment, otherwise I think this looks good!

prometheus_client/metrics.py Outdated Show resolved Hide resolved
@Pliner Pliner force-pushed the add-typing-to-histogram branch from 32535ef to 3d4a632 Compare February 1, 2022 10:53
Signed-off-by: Yury Pliner <yury.pliner@gmail.com>
@Pliner Pliner force-pushed the add-typing-to-histogram branch from 3d4a632 to 02b0053 Compare February 1, 2022 10:55
Copy link
Member

@csmarchbanks csmarchbanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

prometheus_client/metrics.py Show resolved Hide resolved
@csmarchbanks csmarchbanks merged commit ecb5dd9 into prometheus:master Feb 1, 2022
@Pliner Pliner deleted the add-typing-to-histogram branch February 8, 2022 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants