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

Remove choose_formatter before 0.15.0 release #846

Merged
merged 1 commit into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions prometheus_client/exposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
BaseHandler, build_opener, HTTPHandler, HTTPRedirectHandler, HTTPSHandler,
Request,
)
import warnings
from wsgiref.simple_server import make_server, WSGIRequestHandler, WSGIServer

from .openmetrics import exposition as openmetrics
Expand Down Expand Up @@ -249,15 +248,6 @@ def choose_encoder(accept_header: str) -> Tuple[Callable[[CollectorRegistry], by
return generate_latest, CONTENT_TYPE_LATEST


def choose_formatter(accept_header: str) -> Tuple[Callable[[CollectorRegistry], bytes], str]:
warnings.warn(
"choose_formatter is deprecated and will be removed in 0.15.0, please use choose_encoder instead",
DeprecationWarning,
stacklevel=2
)
return choose_encoder(accept_header)


def gzip_accepted(accept_encoding_header: str) -> bool:
accept_encoding_header = accept_encoding_header or ''
for accepted in accept_encoding_header.split(','):
Expand Down
13 changes: 2 additions & 11 deletions tests/test_exposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import threading
import time
import unittest
import warnings

import pytest

Expand All @@ -14,8 +13,8 @@
)
from prometheus_client.core import GaugeHistogramMetricFamily, Timestamp
from prometheus_client.exposition import (
basic_auth_handler, choose_encoder, choose_formatter, default_handler,
MetricsHandler, passthrough_redirect_handler, tls_auth_handler,
basic_auth_handler, choose_encoder, default_handler, MetricsHandler,
passthrough_redirect_handler, tls_auth_handler,
)
import prometheus_client.openmetrics.exposition as openmetrics

Expand Down Expand Up @@ -480,13 +479,5 @@ def test_choose_encoder():
assert choose_encoder(openmetrics.CONTENT_TYPE_LATEST) == (openmetrics.generate_latest, openmetrics.CONTENT_TYPE_LATEST)


def test_choose_formatter():
with warnings.catch_warnings(record=True) as w:
assert choose_formatter('') == (generate_latest, CONTENT_TYPE_LATEST)
assert len(w) == 1
assert issubclass(w[-1].category, DeprecationWarning)
assert "choose_formatter is deprecated" in str(w[-1].message)


if __name__ == '__main__':
unittest.main()