Skip to content

Commit d33e5a8

Browse files
authored
Make mypy tests pass (#190)
1 parent 82805c1 commit d33e5a8

7 files changed

Lines changed: 53 additions & 58 deletions

File tree

.github/workflows/verify_python.sh

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
1-
#!/bin/bash -e
1+
#!/bin/bash
2+
set -eu -o pipefail
23

3-
python3 -m venv venv
4-
source ./venv/bin/activate
5-
pip install --upgrade pip
6-
pip install mypy
7-
pip install pytest pytest-asyncio
8-
pip install types-requests types-Deprecated types-tqdm types-paramiko types-netifaces types-psutil click
9-
pip install ./client
10-
echo "Checking tests files..."
11-
python -m mypy tests --exclude=venv
4+
VENV_DIR=".venv-typing"
5+
6+
function create_venv() {
7+
uv venv ${VENV_DIR}
8+
source ./${VENV_DIR}/bin/activate
9+
}
10+
11+
function cleanup_venv() {
12+
deactivate
13+
rm -rf ${VENV_DIR}
14+
}
15+
16+
create_venv
17+
uv pip install "./client[dev]"
1218
echo "Checking client files (including smoke tests)..."
13-
python -m mypy client --exclude=venv
19+
${VENV_DIR}/bin/python -m mypy client
20+
echo "Checking tests files..."
21+
python -m mypy tests
22+
cleanup_venv
23+
24+
create_venv
25+
uv pip install -r ./environment/aws/requirements.txt
1426
echo "Checking environment setup..."
15-
python -m mypy environment --exclude=venv --explicit-package-bases --check-untyped-defs
27+
python -m mypy environment --explicit-package-bases
28+
cleanup_venv
29+
30+
create_venv
31+
uv pip install -r jenkins/pipelines/requirements.txt
1632
echo "Checking Jenkins pipelines..."
17-
python -m mypy jenkins --exclude=venv --explicit-package-bases
18-
deactivate
19-
rm -rf venv
33+
python -m mypy jenkins --explicit-package-bases
34+
cleanup_venv

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# python
55
__pycache__
66
venv
7+
.venv*
78
.mypy_cache
89
.pytest_cache
910

client/pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ dependencies = [
6363
"yarl==1.18.3",
6464
"zipp==3.21.0",
6565
]
66+
[project.optional-dependencies]
67+
dev = [
68+
"mypy==1.15.0",
69+
]
6670

6771
[project.urls]
6872
"Homepage" = "https://github.com/couchbaselabs/couchbase-lite-tests"

client/requirements.txt

Lines changed: 0 additions & 41 deletions
This file was deleted.

environment/aws/requirements.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
PyNaCl==1.5.0
12
bcrypt==4.2.1
23
certifi==2024.12.14
34
cffi==1.17.1
@@ -6,12 +7,16 @@ click==8.1.8
67
colorama==0.4.6
78
cryptography==44.0.0
89
idna==3.10
10+
mypy==1.15.0
911
netifaces==0.11.0
1012
paramiko==3.5.0
1113
psutil==7.0.0
1214
pycparser==2.22
13-
PyNaCl==1.5.0
1415
requests==2.32.3
1516
tdqm==0.0.1
1617
tqdm==4.67.1
18+
types-netifaces==0.11.0.20241025
19+
types-paramiko==3.5.0.20250516
20+
types-psutil==7.0.0.20250516
21+
types-tqdm==4.67.0.20250516
1722
urllib3==2.3.0

jenkins/pipelines/requirements.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
click==8.2.0
2+
mypy==1.5.0
3+
requests==2.32.3
4+
types-paramiko==3.5.0.20250516
5+
tqdm==4.67.1
6+
types-requests==2.32.0.20250515
7+
types-tqdm==4.67.0.20250516

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
lint.extend-select = ["I"]
33
lint.ignore = ["E402"]
44

5+
[tool.mypy]
6+
check_untyped_defs = true
7+
exclude = "conftest.py" # Exclude conftest.py, since these are duplicated across several test files
8+
59
[[tool.mypy.overrides]]
6-
module = ["couchbase.*", "opentelemetry.exporter.*", "opentelemetry.sdk.*"]
10+
module = "couchbase.*"
711
ignore_missing_imports = true

0 commit comments

Comments
 (0)