Skip to content

Commit 49a8481

Browse files
authored
Fix pydantic lint issues (#64)
* Fix pydantic lint issues * Remove support for python 3.8 * Fix linting * Fix macos test stuck issue * Debugging macos issue
1 parent adc8bcc commit 49a8481

15 files changed

Lines changed: 138 additions & 35 deletions

File tree

.github/workflows/codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: [ubuntu-latest, macos-latest, windows-latest]
17-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
17+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
1818
steps:
1919
- uses: actions/checkout@v4
2020
- name: Set up Python ${{ matrix.python-version }}

.github/workflows/lint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
jobs:
1212
build:
1313
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python-version: ["3.12"]
1417
steps:
1518
- uses: actions/checkout@v4
1619
- name: Set up Python ${{ matrix.python-version }}

Dockerfile.lint

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# syntax=docker/dockerfile:1
2+
FROM python:3.12-slim
3+
4+
WORKDIR /app
5+
6+
# Install system dependencies (if needed)
7+
RUN apt-get update && apt-get install -y \
8+
build-essential \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
# Copy requirements
12+
COPY requirements.txt ./
13+
COPY requirements-lint.txt ./
14+
15+
# Install Python dependencies
16+
RUN pip install --upgrade pip \
17+
&& pip install -r requirements.txt \
18+
&& pip install -r requirements-lint.txt
19+
20+
# Copy the rest of the code
21+
COPY . .
22+
23+
# Run tests (default command)
24+
CMD ["make", "lint"]

Dockerfile.test

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# syntax=docker/dockerfile:1
2+
FROM python:3.13-slim
3+
4+
WORKDIR /app
5+
6+
# Install system dependencies (if needed)
7+
RUN apt-get update && apt-get install -y \
8+
build-essential \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
# Copy requirements
12+
COPY requirements.txt ./
13+
COPY tests/requirements.txt ./tests/
14+
15+
# Install Python dependencies
16+
RUN pip install --upgrade pip \
17+
&& pip install -r requirements.txt \
18+
&& pip install -r tests/requirements.txt
19+
20+
# Copy the rest of the code
21+
COPY zero zero
22+
COPY tests tests
23+
24+
# Run tests (default command)
25+
CMD ["python3", "-m", "pytest", "tests", "--cov=zero", "--cov-report=term-missing", "--cov-config=.coveragerc", "-vv", "--durations=10", "--timeout=280"]

Makefile

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,11 @@ setup:
99
)
1010

1111
test:
12-
python3 -m pytest tests --cov=zero --cov-report=term-missing --cov-config=.coveragerc -vv --durations=10 --timeout=280
12+
python3 -m pytest tests --cov=zero --cov-report=term-missing --cov-config=.coveragerc -vv --durations=10 --timeout=280 -s --exitfirst
1313

1414
docker-test:
15-
docker build -t zero-test -f Dockerfile.test.py38 .
15+
docker build -t zero-test -f Dockerfile.test .
1616
docker run --rm zero-test
17-
docker rmi zero-test
18-
docker build -t zero-test -f Dockerfile.test.py39 .
19-
docker run --rm zero-test
20-
docker rmi zero-test
21-
docker build -t zero-test -f Dockerfile.test.py310 .
22-
docker run --rm zero-test
23-
docker rmi zero-test
2417

2518
format:
2619
isort . --profile black -l 99
@@ -29,14 +22,18 @@ format:
2922
install-lint:
3023
python -m pip install --upgrade pip
3124
pip install -r requirements.txt # needed for pytype
32-
pip install black isort flake8 pylint pytype mypy pydantic>=2.0
25+
pip install -r requirements-lint.txt
3326

3427
lint:
3528
flake8 ./zero
3629
pylint ./zero
3730
pytype ./zero
3831
mypy ./zero
3932

33+
docker-lint:
34+
docker build -t zero-lint -f Dockerfile.lint .
35+
docker run --rm zero-lint
36+
4037
build-package:
4138
pip install -U setuptools wheel
4239
python3 setup.py sdist bdist_wheel

requirements-lint.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
black
2+
isort
3+
flake8
4+
pylint
5+
pytype
6+
mypy
7+
pydantic

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"License :: OSI Approved :: MIT License",
2020
"Operating System :: OS Independent",
2121
],
22-
python_requires=">=3.8",
22+
python_requires=">=3.9",
2323
package_dir={"": "."},
2424
install_requires=["pyzmq", "msgspec"],
2525
extras_require={

tests/conftest.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import subprocess # nosec
2+
from multiprocessing import Process
3+
4+
from tests.utils import kill_process, kill_subprocess, process_map
5+
6+
7+
def pytest_sessionfinish(session, exitstatus):
8+
print("\n")
9+
print("[PYTEST] Session is finishing, exitstatus:", exitstatus)
10+
11+
if process_map.values():
12+
print(
13+
f"[PYTEST] There are {len(process_map)} processes still running at the end of the session:"
14+
)
15+
for process in process_map.values():
16+
print(f" - {process}")
17+
if isinstance(process, subprocess.Popen):
18+
kill_subprocess(process)
19+
print(f" alive: {process.poll() is None}")
20+
elif isinstance(process, Process):
21+
kill_process(process)
22+
print(f" alive: {process.is_alive()}")

tests/functional/multiple_servers/server2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77

88
def echo(msg: str) -> str:
9-
return client.call("echo", msg) # type: ignore
9+
return client.call("echo", msg)
1010

1111

1212
def hello() -> str:
13-
return client.call("hello", None) # type: ignore
13+
return client.call("hello", None)
1414

1515

1616
async def async_echo(msg: str) -> str:

tests/functional/test_pydantic_v1.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import sys
21
import importlib
2+
import sys
33
from typing import Iterator
4+
45
import pytest
56

67

@@ -24,9 +25,6 @@ def test_module_with_pydantic_v1(patch_pydantic_to_v1: None) -> None:
2425

2526
importlib.reload(generic)
2627

27-
# Now run assertions that rely on v1 behavior
28-
assert not generic.IS_PYDANTIC_V2
29-
3028
from pydantic import BaseModel
3129

3230
class TestModel(BaseModel):

0 commit comments

Comments
 (0)