Skip to content

Commit

Permalink
Add mypy linting to the CI pipeline
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Marchbanks <[email protected]>
  • Loading branch information
csmarchbanks committed Jan 26, 2022
1 parent 215d7da commit 978c64d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 17 deletions.
7 changes: 7 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ jobs:
- checkout
- run: pip install tox
- run: tox -e isort
mypy_lint:
executor: python
steps:
- checkout
- run: pip install tox
- run: tox -e mypy
test:
parameters:
python:
Expand Down Expand Up @@ -64,6 +70,7 @@ workflows:
jobs:
- flake8_lint
- isort_lint
- mypy_lint
- test:
matrix:
parameters:
Expand Down
5 changes: 5 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[mypy]
exclude = prometheus_client/decorator.py|prometheus_client/twisted|tests/test_twisted.py

[mypy-prometheus_client.decorator]
follow_imports = skip
6 changes: 1 addition & 5 deletions tests/test_core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from concurrent.futures import ThreadPoolExecutor
import time
import unittest

import pytest

Expand All @@ -11,11 +12,6 @@
)
from prometheus_client.decorator import getargspec

try:
import unittest2 as unittest
except ImportError:
import unittest


def assert_not_observable(fn, *args, **kwargs):
"""
Expand Down
7 changes: 1 addition & 6 deletions tests/test_exposition.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from http.server import BaseHTTPRequestHandler, HTTPServer
import threading
import time
import unittest
Expand All @@ -15,12 +16,6 @@
passthrough_redirect_handler,
)

try:
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
except ImportError:
# Python 3
from http.server import BaseHTTPRequestHandler, HTTPServer


class TestGenerateText(unittest.TestCase):
def setUp(self):
Expand Down
6 changes: 1 addition & 5 deletions tests/test_graphite_bridge.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import socketserver as SocketServer
import threading
import unittest

from prometheus_client import CollectorRegistry, Gauge
from prometheus_client.bridge.graphite import GraphiteBridge

try:
import SocketServer
except ImportError:
import socketserver as SocketServer


def fake_timer():
return 1434898897.5
Expand Down
11 changes: 10 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = coverage-clean,py3.6,py3.7,py3.8,py3.9,py3.10,pypy3.7,py3.9-nooptionals,coverage-report,flake8,isort
envlist = coverage-clean,py3.6,py3.7,py3.8,py3.9,py3.10,pypy3.7,py3.9-nooptionals,coverage-report,flake8,isort,mypy


[base]
Expand Down Expand Up @@ -48,6 +48,15 @@ skip_install = true
commands =
isort --check prometheus_client/ tests/ setup.py

[testenv:mypy]
deps =
pytest
asgiref
mypy==0.910
skip_install = true
commands =
mypy --install-types --non-interactive prometheus_client/ tests/

[flake8]
ignore =
D,
Expand Down

0 comments on commit 978c64d

Please sign in to comment.