Skip to content

Add typing to Histogram/Summary/Gauge#759

Merged
csmarchbanks merged 4 commits into
prometheus:masterfrom
Pliner:add-typing-to-histogram
Feb 1, 2022
Merged

Add typing to Histogram/Summary/Gauge#759
csmarchbanks merged 4 commits into
prometheus:masterfrom
Pliner:add-typing-to-histogram

Conversation

@Pliner

@Pliner Pliner commented Jan 28, 2022

Copy link
Copy Markdown
Contributor

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
self._raise_if_not_observable()

def samples(self) -> Iterable[Sample]:
def samples(_: Gauge) -> Iterable[Sample]:

Copy link
Copy Markdown
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
Copy Markdown
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

Pliner commented Jan 28, 2022

Copy link
Copy Markdown
Contributor Author

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

@csmarchbanks csmarchbanks left a comment

Copy link
Copy Markdown
Member

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.

Comment thread prometheus_client/metrics.py Outdated
Signed-off-by: Yury Pliner <yury.pliner@gmail.com>

@csmarchbanks csmarchbanks left a comment

Copy link
Copy Markdown
Member

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!

Comment thread prometheus_client/metrics.py Outdated
@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
Comment thread prometheus_client/metrics.py

@csmarchbanks csmarchbanks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Awesome, thanks!

Comment thread prometheus_client/metrics.py
@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