Skip to content

Commit a4a2ba9

Browse files
committed
Modernize Makefile.
Replace tox-based lint target with direct uv run commands. Add E704 to flake8 ignores (black requires single-line overload stubs). Fix import ordering in normalized models. Include schema salad and schema-salad-plus-pydantic doc building in linting. Update Makefile for testing and mypy also.
1 parent b8fcc63 commit a4a2ba9

File tree

7 files changed

+39
-20
lines changed

7 files changed

+39
-20
lines changed

.github/workflows/publishdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
python -m pip install -r requirements.txt -r dev-requirements.txt
2222
- name: Build docs
2323
run: |
24-
SKIP_JAVA=1 SKIP_TYPESCRIPT=1 bash build_schema.sh
24+
USE_VENV=0 SKIP_JAVA=1 SKIP_TYPESCRIPT=1 bash build_schema.sh
2525
- name: Deploy Docs
2626
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'galaxyproject'
2727
uses: JamesIves/github-pages-deploy-action@releases/v4

Makefile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,19 @@ setup-git-hook-lint: ## setup precommit hook for linting project
5959
setup-git-hook-lint-and-test: ## setup precommit hook for linting and testing project
6060
cp $(BUILD_SCRIPTS_DIR)/pre-commit-lint-and-test .git/hooks/pre-commit
6161

62-
flake8: ## check style using flake8 for current Python (faster than lint)
63-
$(IN_VENV) flake8 --max-complexity 11 $(SOURCE_DIR) $(TEST_DIR)
64-
65-
lint: ## check style using tox and flake8 for Python 2 and Python 3
66-
$(IN_VENV) tox -e py36-lint && tox -e py39-lint
62+
lint: ## check style with ruff, flake8, black, and mypy
63+
uv run --group lint ruff check
64+
uv run --group lint flake8
65+
uv run --group lint black --check --diff .
66+
uv run --group mypy mypy gxformat2
67+
SKIP_JAVA=1 SKIP_TYPESCRIPT=1 GXFORMAT2_SCHEMA_BUILD_DRY_RUN=1 bash build_schema.sh
6768

6869
lint-docs: ready-docs
6970
$(IN_VENV) $(MAKE) -C $(DOCS_DIR) clean
7071
$(IN_VENV) $(MAKE) -C $(DOCS_DIR) html 2>&1 | python $(BUILD_SCRIPTS_DIR)/lint_sphinx_output.py
7172

7273
test: ## run tests with the default Python (faster than tox)
73-
$(IN_VENV) nosetests $(NOSE_TESTS)
74+
uv run --group test pytest tests/
7475

7576
tox: ## run tests with tox in the specified ENV
7677
$(IN_VENV) tox -e $(ENV) -- $(ARGS)
@@ -127,4 +128,4 @@ format:
127128
uv run --group lint black .
128129

129130
mypy:
130-
MYPYPATH=mypy-stubs mypy gxformat2
131+
uv run --group mypy mypy gxformat2

build_schema.sh

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ set -x
44
set -e
55

66
PROJECT_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
7+
USE_VENV=${USE_VENV:-"1"}
8+
if [ "$USE_VENV" != "0" ]; then
9+
if [ -f "${PROJECT_DIRECTORY}/.venv/bin/activate" ]; then
10+
source "${PROJECT_DIRECTORY}/.venv/bin/activate"
11+
else
12+
echo "ERROR: USE_VENV=${USE_VENV} but ${PROJECT_DIRECTORY}/.venv/bin/activate not found" >&2
13+
exit 1
14+
fi
15+
fi
16+
17+
GXFORMAT2_SCHEMA_BUILD_DRY_RUN=${GXFORMAT2_SCHEMA_BUILD_DRY_RUN:-"0"}
18+
SCHEME_SOURCE_DIRECTORY="${PROJECT_DIRECTORY}/gxformat2/schema"
19+
if [ "${GXFORMAT2_SCHEMA_BUILD_DRY_RUN}" = "1" ]; then
20+
SCHEME_SOURCE_DIRECTORY="$(mktemp -d -t gxformat2-schema.XXXXXX)"
21+
echo "GXFORMAT2_SCHEMA_BUILD_DRY_RUN=1; writing generated schemas to ${SCHEME_SOURCE_DIRECTORY}" >&2
22+
fi
23+
mkdir -p "${SCHEME_SOURCE_DIRECTORY}"
724
SKIP_JAVA=${SKIP_JAVA:-0}
825
SKIP_TYPESCRIPT=${SKIP_TYPESCRIPT:-0}
926
DIST_DIRECTORY="${PROJECT_DIRECTORY}/dist/schema"
@@ -17,7 +34,7 @@ for schema in "v19_09";
1734
do
1835
cd schema/"$schema";
1936
python_schema_name=${schema//./_}
20-
schema-salad-tool --codegen python workflow.yml > "${PROJECT_DIRECTORY}/gxformat2/schema/${python_schema_name}.py"
37+
schema-salad-tool --codegen python workflow.yml > "${SCHEME_SOURCE_DIRECTORY}/${python_schema_name}.py"
2138

2239
out="${DIST_DIRECTORY}/${schema}.html"
2340
schema-salad-doc \
@@ -58,7 +75,7 @@ done
5875

5976
# Native workflow format schema
6077
cd "${PROJECT_DIRECTORY}"/schema/native_v0_1
61-
schema-salad-tool --codegen python workflow.yml > "${PROJECT_DIRECTORY}/gxformat2/schema/native_v0_1.py"
78+
schema-salad-tool --codegen python workflow.yml > "${SCHEME_SOURCE_DIRECTORY}/native_v0_1.py"
6279

6380
out="${DIST_DIRECTORY}/native_v0_1.html"
6481
schema-salad-doc \
@@ -76,10 +93,10 @@ schema-salad-doc \
7693
SKIP_PYDANTIC=${SKIP_PYDANTIC:-0}
7794
if [ $SKIP_PYDANTIC -eq 0 ]; then
7895
cd "${PROJECT_DIRECTORY}"
79-
schema-salad-plus-pydantic generate schema/v19_09/workflow.yml -o gxformat2/schema/gxformat2.py
80-
schema-salad-plus-pydantic generate schema/v19_09/workflow.yml --strict -o gxformat2/schema/gxformat2_strict.py
81-
schema-salad-plus-pydantic generate schema/native_v0_1/workflow.yml -o gxformat2/schema/native.py
82-
schema-salad-plus-pydantic generate schema/native_v0_1/workflow.yml --strict -o gxformat2/schema/native_strict.py
96+
schema-salad-plus-pydantic generate schema/v19_09/workflow.yml -o "${SCHEME_SOURCE_DIRECTORY}/gxformat2.py"
97+
schema-salad-plus-pydantic generate schema/v19_09/workflow.yml --strict -o "${SCHEME_SOURCE_DIRECTORY}/gxformat2_strict.py"
98+
schema-salad-plus-pydantic generate schema/native_v0_1/workflow.yml -o "${SCHEME_SOURCE_DIRECTORY}/native.py"
99+
schema-salad-plus-pydantic generate schema/native_v0_1/workflow.yml --strict -o "${SCHEME_SOURCE_DIRECTORY}/native_strict.py"
83100
schema-salad-plus-pydantic enhance-docs schema/native_v0_1/workflow.yml "${DIST_DIRECTORY}/native_v0_1.html"
84101
else
85102
# Fallback post-processing without schema-salad-plus-pydantic

gxformat2/normalized/_expanded.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
class ExpandedWorkflowStep(NormalizedWorkflowStep):
2929
"""Format2 step with run fully resolved — no ImportReference remaining."""
3030

31-
run: ExpandedFormat2 | GalaxyUserToolStub | None = Field(default=None, description="Resolved subworkflow, user tool, or absent.")
31+
run: ExpandedFormat2 | GalaxyUserToolStub | None = Field(
32+
default=None, description="Resolved subworkflow, user tool, or absent."
33+
)
3234

3335

3436
class ExpandedFormat2(NormalizedFormat2):

gxformat2/normalized/_format2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
from pathlib import Path
1313
from typing import Any, Literal, Union
1414

15-
from typing_extensions import TypeAlias
16-
1715
from pydantic import BaseModel, ConfigDict, Field, field_validator
16+
from typing_extensions import TypeAlias
1817

1918
from gxformat2.schema.gxformat2 import (
2019
CreatorOrganization,

gxformat2/normalized/_native.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
from pathlib import Path
1313
from typing import Annotated, Any, Union
1414

15-
from typing_extensions import TypeAlias
16-
1715
from pydantic import BaseModel, ConfigDict, Discriminator, Field, Tag
16+
from typing_extensions import TypeAlias
1817

1918
from gxformat2.native import load_native
2019
from gxformat2.schema.native import (

setup.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ logging-filter=gxformat2
1414
logging-level=INFO
1515

1616
[flake8]
17-
ignore = E203,E501,W503
17+
# E704: black formats overload stubs as single-line `def foo(): ...`
18+
ignore = E203,E501,E704,W503
1819
max-complexity = 30
1920
import-order-style = smarkets
2021
application-import-names = gxformat2,tests

0 commit comments

Comments
 (0)