summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Parise <jon@pinterest.com>2022-02-20 11:54:47 -0800
committerGitHub <noreply@github.com>2022-02-20 11:54:47 -0800
commita2be8250c68b22315e278686b9e57c2dcbee3b62 (patch)
tree34d63048a1c57eaf50c5bf88edfe0d13cfb469c0
parent900fc18db76a4e20c77f748bcffff2055231a3b5 (diff)
downloadpymemcache-a2be8250c68b22315e278686b9e57c2dcbee3b62.tar.gz
Initial support for mypy-based type checking (#373)
-rw-r--r--.github/workflows/ci.yml2
-rw-r--r--mypy-requirements.txt2
-rw-r--r--pymemcache/test/conftest.py2
-rw-r--r--pymemcache/test/test_benchmark.py4
-rw-r--r--pyproject.toml3
-rw-r--r--tox.ini7
6 files changed, 16 insertions, 4 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 6ee0977..af554c0 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -34,7 +34,7 @@ jobs:
- name: Lint
if: matrix.python-version == '3.10'
run: |
- tox -e lint
+ tox -e lint,mypy
- name: Disable IPv6 localhost
run: |
sudo sed -i '/::1/d' /etc/hosts
diff --git a/mypy-requirements.txt b/mypy-requirements.txt
new file mode 100644
index 0000000..75c00be
--- /dev/null
+++ b/mypy-requirements.txt
@@ -0,0 +1,2 @@
+-r test-requirements.txt
+mypy==0.931
diff --git a/pymemcache/test/conftest.py b/pymemcache/test/conftest.py
index befd70d..e8b8bdf 100644
--- a/pymemcache/test/conftest.py
+++ b/pymemcache/test/conftest.py
@@ -91,7 +91,7 @@ def pytest_generate_tests(metafunc):
if "socket_module" in metafunc.fixturenames:
socket_modules = [socket]
try:
- from gevent import socket as gevent_socket
+ from gevent import socket as gevent_socket # type: ignore
except ImportError:
print("Skipping gevent (not installed)")
else:
diff --git a/pymemcache/test/test_benchmark.py b/pymemcache/test/test_benchmark.py
index 61cd96a..55653bd 100644
--- a/pymemcache/test/test_benchmark.py
+++ b/pymemcache/test/test_benchmark.py
@@ -16,14 +16,14 @@ import time
import pytest
try:
- import pylibmc
+ import pylibmc # type: ignore
HAS_PYLIBMC = True
except Exception:
HAS_PYLIBMC = False
try:
- import memcache
+ import memcache # type: ignore
HAS_MEMCACHE = True
except Exception:
diff --git a/pyproject.toml b/pyproject.toml
index 649ed75..8d26def 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,2 +1,5 @@
[tool.black]
target-version = ['py37', 'py38', 'py39', 'py310']
+
+[tool.mypy]
+python_version = 3.7
diff --git a/tox.ini b/tox.ini
index 388c35a..dc39912 100644
--- a/tox.ini
+++ b/tox.ini
@@ -7,6 +7,7 @@ envlist =
pypy3,
docs,
lint,
+ mypy,
venv,
skip_missing_interpreters = true
@@ -29,6 +30,12 @@ commands =
flake8
black --check .
+[testenv:mypy]
+description = type check source code
+deps = -r{toxinidir}/mypy-requirements.txt
+commands =
+ python -m mypy -p pymemcache
+
[testenv:docs]
description = invoke sphinx-build to build the HTML docs
deps = -r{toxinidir}/docs-requirements.txt