Skip to content

Commit 340b5d2

Browse files
committed
Simplify running checks locally
This patch refactors some of the GH workflow checks that we are running in the gate to make it eaier to run locally. That way we can verify the code prior to pushing it as a PR. $ pdm verify Signed-off-by: Lucas Alvares Gomes <lucasagomes@gmail.com>
1 parent d55c77c commit 340b5d2

File tree

10 files changed

+154
-19
lines changed

10 files changed

+154
-19
lines changed

.github/workflows/black.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
- name: Black version
2525
run: pdm run black --version
2626
- name: Black check
27-
run: pdm run black . --check
27+
run: make black

.github/workflows/mypy.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ jobs:
1717
python-version: '3.11'
1818
- name: Python version
1919
run: python --version
20-
- name: Mypy installation
21-
run: pip install --user mypy pydantic types-PyYAML
22-
- name: Type checks
23-
run: mypy --explicit-package-bases --disallow-untyped-calls --disallow-untyped-defs --disallow-incomplete-defs --ignore-missing-imports --disable-error-code attr-defined src/
20+
- name: PDM installation
21+
run: pip install --user pdm
22+
- name: Install dependencies
23+
run: pdm install
24+
- name: Install devel dependencies
25+
run: pdm install --group default,dev
26+
- name: Python linter
27+
run: make check-types

.github/workflows/pydocstyle.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ jobs:
1717
python-version: '3.11'
1818
- name: Python version
1919
run: python --version
20-
- name: Pydocstyle install
21-
run: pip install --user pydocstyle
22-
- name: Python docstring checks
23-
run: pydocstyle -v .
20+
- name: PDM installation
21+
run: pip install --user pdm
22+
- name: Install dependencies
23+
run: pdm install
24+
- name: Install devel dependencies
25+
run: pdm install --group default,dev
26+
- name: Python linter
27+
run: make docstyle

.github/workflows/pylint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ jobs:
2525
- name: Install devel dependencies
2626
run: pdm install --group default,dev
2727
- name: Python linter
28-
run: pdm run pylint src
28+
run: make pylint

.github/workflows/pyright.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ jobs:
2525
- name: Install devel dependencies
2626
run: pdm install --group default,dev
2727
- name: Run Pyright tests
28-
run: pdm run pyright src
28+
run: make pyright

.github/workflows/ruff.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,16 @@ jobs:
1212
pull-requests: read
1313
steps:
1414
- uses: actions/checkout@v4
15-
- uses: chartboost/ruff-action@v1
15+
- uses: actions/setup-python@v5
1616
with:
17-
args: 'check . --per-file-ignores=tests/*:S101 --per-file-ignores=scripts/*:S101'
18-
17+
python-version: '3.11'
18+
- name: Python version
19+
run: python --version
20+
- name: PDM installation
21+
run: pip install --user pdm
22+
- name: Install dependencies
23+
run: pdm install
24+
- name: Install devel dependencies
25+
run: pdm install --group default,dev
26+
- name: Python linter
27+
run: make ruff

Makefile

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test-integration: ## Run integration tests tests
1616
COVERAGE_FILE="${ARTIFACT_DIR}/.coverage.integration" pdm run pytest tests/integration --cov=src --cov-report term-missing --cov-report "json:${ARTIFACT_DIR}/coverage_integration.json" --junit-xml="${ARTIFACT_DIR}/junit_integration.xml" --cov-fail-under=10
1717

1818
check-types: ## Checks type hints in sources
19-
MYPYPATH=src pdm run mypy --namespace-packages --explicit-package-bases --strict --disallow-untyped-calls --disallow-untyped-defs --disallow-incomplete-defs src
19+
pdm run mypy --explicit-package-bases --disallow-untyped-calls --disallow-untyped-defs --disallow-incomplete-defs --ignore-missing-imports --disable-error-code attr-defined src/
2020

2121
security-check: ## Check the project for security issues
2222
bandit -c pyproject.toml -r src tests
@@ -43,3 +43,25 @@ shellcheck: ## Run shellcheck
4343
shellcheck --version
4444
shellcheck -- */*.sh
4545

46+
black:
47+
pdm run black --check .
48+
49+
pylint:
50+
pdm run pylint src
51+
52+
pyright:
53+
pdm run pyright src
54+
55+
docstyle:
56+
pdm run pydocstyle -v .
57+
58+
ruff:
59+
pdm run ruff check . --per-file-ignores=tests/*:S101 --per-file-ignores=scripts/*:S101
60+
61+
verify:
62+
$(MAKE) black
63+
$(MAKE) pylint
64+
$(MAKE) pyright
65+
$(MAKE) ruff
66+
$(MAKE) docstyle
67+
$(MAKE) check-types

pdm.lock

Lines changed: 94 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ dev = [
2626
"pytest-asyncio>=1.0.0",
2727
"pyright>=1.1.401",
2828
"pylint>=3.3.7",
29+
"pydocstyle>=6.3.0",
30+
"mypy>=1.16.0",
31+
"types-PyYAML>=6.0.2",
32+
"ruff>=0.11.13",
2933
]
3034

3135
[tool.pytest.ini_options]
@@ -47,4 +51,5 @@ distribution = true
4751
start = "pdm run make run"
4852
test-unit = "pdm run make test-unit"
4953
test-integration = "pdm run make test-integration"
54+
verify = "pdm run make verify"
5055

src/app/endpoints/query.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@ def retrieve_response(
127127
stream=False,
128128
)
129129

130-
return str(
131-
response.output_message.content # pyright: ignore[reportAttributeAccessIssue]
132-
)
130+
return str(response.output_message.content) # type: ignore[union-attr]
133131

134132

135133
def validate_attachments_metadata(attachments: list[Attachment]) -> None:

0 commit comments

Comments
 (0)