8000 Merge pull request #706 from hugovk/add-3.10 · reinaldoca/client_python@6650d07 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6650d07

Browse files
authored
Merge pull request prometheus#706 from hugovk/add-3.10
Add support for Python 3.10
2 parents c8f1bd3 + bf1e7dc commit 6650d07

13 files changed

+14
-78
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ workflows:
7575
- "3.7"
7676
- "3.8"
7777
- "3.9"
78+
- "3.10"
7879
- test_nooptionals:
7980
matrix:
8081
parameters:

prometheus_client/exposition.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
CONTENT_TYPE_LATEST = str('text/plain; version=0.0.4; charset=utf-8')
3535
"""Content type of the latest text format"""
3636
PYTHON27_OR_OLDER = sys.version_info < (3, )
37-
PYTHON26_OR_OLDER = sys.version_info < (2, 7)
3837
PYTHON376_OR_NEWER = sys.version_info > (3, 7, 5)
3938

4039

@@ -445,7 +444,7 @@ def _use_gateway(method, gateway, job, registry, grouping_key, timeout, handler)
445444
gateway_url = urlparse(gateway)
446445
# See https://bugs.python.org/issue27657 for details on urlparse in py>=3.7.6.
447446
if not gateway_url.scheme or (
448-
(PYTHON376_OR_NEWER or PYTHON26_OR_OLDER)
447+
PYTHON376_OR_NEWER
449448
and gateway_url.scheme not in ['http', 'https']
450449
):
451450
gateway = 'http://{0}'.format(gateway)

setup.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
from os import path
2-
import sys
32

43
from setuptools import setup
54

6-
if sys.version_info >= (2, 7):
7-
with open(path.join(path.abspath(path.dirname(__file__)), 'README.md')) as f:
8-
long_description = f.read()
9-
else: # Assuming we don't run setup in order to publish under python 2.6
10-
long_description = "NA"
5+
with open(path.join(path.abspath(path.dirname(__file__)), 'README.md')) as f:
6+
long_description = f.read()
117

128

139
setup(
@@ -47,6 +43,7 @@
4743
"Programming Language :: Python :: 3.7",
4844
"Programming Language :: Python :: 3.8",
4945
"Programming Language :: Python :: 3.9",
46+
"Programming Language :: Python :: 3.10",
5047
"Programming Language :: Python :: Implementation :: CPython",
5148
"Programming Language :: Python :: Implementation :: PyPy",
5249
"Topic :: System :: Monitoring",

tests/openmetrics/test_exposition.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import unicode_literals
22

3-
import sys
43
import time
4+
import unittest
55

66
from prometheus_client import (
77
CollectorRegistry, Counter, Enum, Gauge, Histogram, Info, Metric, Summary,
@@ -11,12 +11,6 @@
1111
)
1212
from prometheus_client.openmetrics.exposition import generate_latest
1313

14-
if sys.version_info < (2, 7):
15-
# We need the skip decorators from unittest2 on Python 2.6.
16-
import unittest2 as unittest
17-
else:
18-
import unittest
19-
2014

2115
class TestGenerateText(unittest.TestCase):
2216
def setUp(self):

tests/openmetrics/test_parser.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import math
44
import sys
5+
import unittest
56

67
from prometheus_client.core import (
78
CollectorRegistry, CounterMetricFamily, Exemplar,
@@ -12,12 +13,6 @@
1213
from prometheus_client.openmetrics.exposition import generate_latest
1314
from prometheus_client.openmetrics.parser import text_string_to_metric_families
1415

15-
if sys.version_info < (2, 7):
16-
# We need the skip decorators from unittest2 on Python 2.6.
17-
import unittest2 as unittest
18-
else:
19-
import unittest
20-
2116

2217
class TestParse(unittest.TestCase):
2318

@@ -549,7 +544,6 @@ def test_fallback_to_state_machine_label_parsing(self):
549544
mock2.assert_not_called()
550545
mock3.assert_called_once_with('1')
551546

552-
@unittest.skipIf(sys.version_info < (2, 7), "Test requires Python 2.7+.")
553547
def test_roundtrip(self):
554548
text = """# HELP go_gc_duration_seconds A summary of the GC invocation durations.
555549
# TYPE go_gc_duration_seconds summary

tests/test_asgi.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
from __future__ import absolute_import, unicode_literals
22

3-
import sys
4-
from unittest import TestCase
3+
from unittest import skipUnless, TestCase
54

65
from prometheus_client import CollectorRegistry, Counter
76
from prometheus_client.exposition import CONTENT_TYPE_LATEST
87

9-
if sys.version_info < (2, 7):
10-
from unittest2 import skipUnless
11-
else:
12-
from unittest import skipUnless
13-
148
try:
159
# Python >3.5 only
1610
import asyncio

tests/test_exposition.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from __future__ import unicode_literals
22

3-
import sys
43
import threading
54
import time
5+
import unittest
66

77
import pytest
88

@@ -17,12 +17,6 @@
1717
passthrough_redirect_handler,
1818
)
1919

20-
if sys.version_info < (2, 7):
21-
# We need the skip decorators from unittest2 on Python 2.6.
22-
import unittest2 as unittest
23-
else:
24-
import unittest
25-
2620
try:
2721
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
2822
except ImportError:
@@ -98,7 +92,6 @@ def test_summary(self):
9892
ss_created{a="c",b="d"} 123.456
9993
""", generate_latest(self.registry))
10094

101-
@unittest.skipIf(sys.version_info < (2, 7), "Test requires Python 2.7+.")
10295
def test_histogram(self):
10396
s = Histogram('hh', 'A histogram', registry=self.registry)
10497
s.observe(0.05)

tests/test_gc_collector.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
import gc
44
import platform
55
import sys
6-
7-
if sys.version_info < (2, 7):
8-
# We need the skip decorators from unittest2 on Python 2.6.
9-
import unittest2 as unittest
10-
else:
11< F987 code class="diff-text syntax-highlighted-line deletion">-
import unittest
6+
import unittest
127

138
from prometheus_client import CollectorRegistry, GCCollector
149

tests/test_multiprocess.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import glob
44
import os
55
import shutil
6-
import sys
76
import tempfile
7+
import unittest
88
import warnings
99

1010
from prometheus_client import mmap_dict, values
@@ -18,12 +18,6 @@
1818
get_value_class, MultiProcessValue, MutexValue,
1919
)
2020

21-
if sys.version_info < (2, 7):
22-
# We need the skip decorators from unittest2 on Python 2.6.
23-
import unittest2 as unittest
24-
else:
25-
import unittest
26-
2721

2822
class TestMultiProcessDeprecation(unittest.TestCase):
2923
def setUp(self):
@@ -196,7 +190,6 @@ def files():
196190
c3 = Counter('c3', 'c3', registry=None)
197191
self.assertEqual(files(), ['counter_0.db', 'counter_1.db'])
198192

199-
@unittest.skipIf(sys.version_info < (2, 7), "Test requires Python 2.7+.")
200193
def test_collect(self):
201194
pid = 0
202195
values.ValueClass = MultiProcessValue(lambda: pid)
@@ -257,7 +250,6 @@ def add_label(key, value):
257250

258251
self.assertEqual(metrics['h'].samples, expected_histogram)
259252

260-
@unittest.skipIf(sys.version_info < (2, 7), "Test requires Python 2.7+.")
261253
def test_merge_no_accumulate(self):
262254
pid = 0
263255
values.ValueClass = MultiProcessValue(lambda: pid)

tests/test_parser.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import unicode_literals
22

33
import math
4-
import sys
4+
import unittest
55

66
from prometheus_client.core import (
77
CollectorRegistry, CounterMetricFamily, GaugeMetricFamily,
@@ -10,12 +10,6 @@
1010
from prometheus_client.exposition import generate_latest
1111
from prometheus_client.parser import text_string_to_metric_families
1212

13-
if sys.version_info < (2, 7):
14-
# We need the skip decorators from unittest2 on Python 2.6.
15-
import unittest2 as unittest
16-
else:
17-
import unittest
18-
1913

2014
class TestParse(unittest.TestCase):
2115
def assertEqualMetrics(self, first, second, msg=None):
@@ -289,7 +283,6 @@ def test_timestamps(self):
289283
b.add_metric([], 88, timestamp=1234566)
290284
self.assertEqualMetrics([a, b], list(families))
291285

292-
@unittest.skipIf(sys.version_info < (2, 7), "Test requires Python 2.7+.")
293286
def test_roundtrip(self):
294287
text = """# HELP go_gc_duration_seconds A summary of the GC invocation durations.
295288
# TYPE go_gc_duration_seconds summary

tests/test_twisted.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
from __future__ import absolute_import, unicode_literals
22

3-
import sys
3+
from unittest import skipUnless
44

55
from prometheus_client import CollectorRegistry, Counter, generate_latest
66

7-
if sys.version_info < (2, 7):
8-
from unittest2 import skipUnless
9-
else:
10-
from unittest import skipUnless
11-
127
try:
138
from twisted.internet import reactor
149
from twisted.trial.unittest import TestCase

tests/test_wsgi.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,6 @@ def capture(self, status, header):
2222
self.captured_status = status
2323
self.captured_headers = header
2424

25-
def assertIn(self, item, iterable):
26-
try:
27-
super().assertIn(item, iterable)
28-
except: # Python < 2.7
29-
self.assertTrue(
30-
item in iterable,
31-
msg="{item} not found in {iterable}".format(
32-
item=item, iterable=iterable
33-
)
34-
)
35-
3625
def validate_metrics(self, metric_name, help_text, increments):
3726
"""
3827
WSGI app serves the metrics from the provided registry.

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = coverage-clean,py2.7,py3.4,py3.5,py3.6,py3.7,py3.8,py3.9,pypy2.7,pypy3.7,{py2.7,py3.9}-nooptionals,coverage-report,flake8,isort
2+
envlist = coverage-clean,py2.7,py3.4,py3.5,py3.6,py3.7,py3.8,py3.9,py3.10,pypy2.7,pypy3.7,{py2.7,py3.9}-nooptionals,coverage-report,flake8,isort
33

44

55
[base]

0 commit comments

Comments
 (0)
0