8000 Add mypy linting to the CI pipeline · dirkhusemann/client_python@cd4cf2e · GitHub
[go: up one dir, main page]

Skip to content

Commit cd4cf2e

Browse files
committed
Add mypy linting to the CI pipeline
Signed-off-by: Chris Marchbanks <csmarchbanks@gmail.com>
1 parent 4b7811a commit cd4cf2e

File tree

6 files changed

+25
-17
lines changed

6 files changed

+25
-17
lines changed

.circleci/config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ jobs:
1919
- checkout
2020
- run: pip install tox
2121
- run: tox -e isort
22+
mypy_lint:
23+
executor: python
24+
steps:
25+
- checkout
26+
- run: pip install tox
27+
- run: tox -e mypy
2228
test:
2329
parameters:
2430
python:
@@ -64,6 +70,7 @@ workflows:
6470
jobs:
6571
- flake8_lint
6672
- isort_lint
73+
- mypy_lint
6774
- test:
6875
matrix:
6976
parameters:

mypy.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numbe 10000 rDiff line change
@@ -0,0 +1,5 @@
1+
[mypy]
2+
exclude = prometheus_client/decorator.py|prometheus_client/twisted|tests/test_twisted.py
3+
4+
[mypy-prometheus_client.decorator]
5+
follow_imports = skip

tests/test_core.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from concurrent.futures import ThreadPoolExecutor
22
import time
3+
import unittest
34

45
import pytest
56

@@ -11,11 +12,6 @@
1112
)
1213
from prometheus_client.decorator import getargspec
1314

14-
try:
15-
import unittest2 as unittest
16-
except ImportError:
17-
import unittest
18-
1915

2016
def assert_not_observable(fn, *args, **kwargs):
2117
"""

tests/test_exposition.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from http.server import BaseHTTPRequestHandler, HTTPServer
12
import threading
23
import time
34
import unittest
@@ -15,12 +16,6 @@
1516
passthrough_redirect_handler,
1617
)
1718

18-
try:
19-
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
20-
except ImportError:
21-
# Python 3
22-
from http.server import BaseHTTPRequestHandler, HTTPServer
23-
2419

2520
class TestGenerateText(unittest.TestCase):
2621
def setUp(self):

tests/test_graphite_bridge.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1+
import socketserver as SocketServer
12
import threading
23
import unittest
34

45
from prometheus_client import CollectorRegistry, Gauge
56
from prometheus_client.bridge.graphite import GraphiteBridge
67

7-
try:
8-
import SocketServer
9-
except ImportError:
10-
import socketserver as SocketServer
11-
128

139
def fake_timer():
1410
return 1434898897.5

tox.ini

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

44

55
[base]
@@ -48,6 +48,15 @@ skip_install = true
4848
commands =
4949
isort --check prometheus_client/ tests/ setup.py
5050

51+
[testenv:mypy]
52+
deps =
53+
pytest
54+
asgiref
55+
mypy==0.910
56+
skip_install = true
57+
commands =
58+
mypy --install-types --non-interactive prometheus_client/ tests/
59+
5160
[flake8]
5261
ignore =
5362
D,

0 commit comments

Comments
 (0)
0