Skip to content

Commit a2dbd00

Browse files
committed
Added some linting and tooling update
Signed-off-by: Albert Callarisa <albert@diagrid.io>
1 parent f87ba19 commit a2dbd00

File tree

5 files changed

+78
-24
lines changed

5 files changed

+78
-24
lines changed

.flake8

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

.github/workflows/pr-validation.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ jobs:
2828
- name: Install dependencies
2929
run: |
3030
python -m pip install --upgrade pip
31-
pip install flake8 pytest pytest-cov pytest-asyncio
32-
pip install -r requirements.txt
33-
- name: Lint with flake8
31+
pip install .[dev]
32+
- name: Lint with ruff
3433
run: |
35-
flake8 . --count --show-source --statistics --exit-zero
34+
ruff check
3635
- name: Pytest unit tests
3736
run: |
38-
pytest -m "not e2e" --verbose
37+
tox -e py${{ matrix.python-version }}
3938
# Sidecar for running e2e tests requires Go SDK
4039
- name: Install Go SDK
4140
uses: actions/setup-go@v5
@@ -47,6 +46,7 @@ jobs:
4746
go install github.com/dapr/durabletask-go@main
4847
durabletask-go --port 4001 &
4948
pytest -m "e2e" --verbose
49+
tox -e py${{ matrix.python-version }} -- e2e
5050
publish:
5151
needs: build
5252
if: startswith(github.ref, 'refs/tags/v')
@@ -70,4 +70,4 @@ jobs:
7070
TWINE_PASSWORD: ${{ secrets.PYPI_UPLOAD_PASS }}
7171
run: |
7272
python -m build
73-
twine upload dist/*
73+
twine upload dist/*

pyproject.toml

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ keywords = [
1717
"workflow"
1818
]
1919
classifiers = [
20-
"Development Status :: 3 - Alpha",
21-
"Programming Language :: Python :: 3",
22-
"License :: OSI Approved :: MIT License",
20+
"Development Status :: 3 - Alpha",
21+
"Programming Language :: Python :: 3",
22+
"License :: OSI Approved :: MIT License",
2323
]
2424
requires-python = ">=3.9"
2525
license = {file = "LICENSE"}
2626
readme = "README.md"
2727
dependencies = [
2828
"grpcio",
29-
"protobuf>=6.31.1,<7.0.0", # follows grpcio generation version https://github.com/grpc/grpc/blob/v1.74.0/tools/distrib/python/grpcio_tools/setup.py
29+
"protobuf>=6.31.1,<7.0.0", # follows grpcio generation version https://github.com/grpc/grpc/blob/v1.75.1/tools/distrib/python/grpcio_tools/setup.py
3030
"asyncio"
3131
]
3232

@@ -48,3 +48,36 @@ pythonpath = ["."]
4848
markers = [
4949
"e2e: mark a test as an end-to-end test that requires a running sidecar"
5050
]
51+
52+
[project.optional-dependencies]
53+
dev = [
54+
"pytest",
55+
"pytest-asyncio>=0.23",
56+
"tox>=4.0.0",
57+
"pytest-cov",
58+
"ruff",
59+
60+
# grpc gen
61+
"grpcio-tools==1.75.1",
62+
]
63+
64+
[tool.ruff]
65+
target-version = "py310" # TODO: update to py310 when we drop support for py39
66+
line-length = 100
67+
extend-exclude = [".github", "durabletask/internal/orchestrator_service_*.*"]
68+
69+
[tool.ruff.lint]
70+
select = [
71+
"I", # isort
72+
"W", # pycodestyle warnings
73+
"F", # pyflakes
74+
75+
# TODO: Add those back progressively as we fix the issues
76+
# "E", # pycodestyle errors
77+
# "C", # flake8-comprehensions
78+
# "B", # flake8-bugbear
79+
# "UP", # pyupgrade
80+
]
81+
82+
[tool.ruff.format]
83+
quote-style = "double"

requirements.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
1-
autopep8
2-
grpcio>=1.60.0 # 1.60.0 is the version introducing protobuf 1.25.X support, newer versions are backwards compatible
3-
protobuf
4-
asyncio
5-
pytest
6-
pytest-cov
7-
pytest-asyncio
8-
flake8
1+
# requirements in pyproject.toml

tox.ini

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[tox]
2+
skipsdist = True
3+
minversion = 3.10.0
4+
envlist =
5+
py{39,310,311,312,313,314}
6+
ruff,
7+
mypy,
8+
# TODO: switch runner to uv (tox-uv plugin)
9+
runner = virtualenv
10+
11+
[testenv]
12+
# you can run tox with the e2e pytest marker using tox factors:
13+
# tox -e py39,py310,py311,py312,py313,py314 -- e2e
14+
# or single one with:
15+
# tox -e py310-e2e
16+
# to use custom grpc endpoint and not capture print statements (-s arg in pytest):
17+
# DAPR_GRPC_ENDPOINT=localhost:12345 tox -e py310-e2e -- -s
18+
setenv =
19+
PYTHONDONTWRITEBYTECODE=1
20+
deps = .[dev]
21+
commands =
22+
!e2e: pytest {posargs} -m "not e2e" --verbose
23+
e2e: pytest {posargs} -m e2e --verbose
24+
commands_pre =
25+
pip3 install -e {toxinidir}/
26+
allowlist_externals = pip3
27+
pass_env = DAPR_GRPC_ENDPOINT,DAPR_HTTP_ENDPOINT,DAPR_RUNTIME_HOST,DAPR_GRPC_PORT,DAPR_HTTP_PORT
28+
29+
[testenv:ruff]
30+
basepython = python3
31+
usedevelop = False
32+
commands =
33+
ruff check --fix
34+
ruff format

0 commit comments

Comments
 (0)