Skip to content

Commit 47087af

Browse files
feat: add stapi-fastapi (#10)
Move the [stapi-fastapi](https://github.com/stapi-spec/stapi-fastapi) into this monorepo for STAPI Python reference implementations. 1. Copied the source code from the old repository into `stapi-fastapi`. 2. Make its `pyproject.toml` ready for uv. 3. Move the `.pre-commit-config.yaml` and linter and formatter configuration to the top `pyproject.toml`. 4. Make `pytest` work for both sub-packages. Unfortunately, you cannot build the packages for both projects with one execution of `uv build `. You have to execute it like this for each sub-project: `uv build --package stapi-fastapi`. --------- Co-authored-by: Pete Gadomski <[email protected]>
1 parent df5d6d3 commit 47087af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+4689
-32
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ jobs:
1919
- uses: astral-sh/setup-uv@v5
2020
- name: Sync
2121
run: uv sync
22-
- name: Lint
23-
run: scripts/lint
22+
- name: Pre-Commit Hooks
23+
run: uv run pre-commit run --all-files
2424
- name: Test
2525
run: uv run pytest
2626
- name: Docs
2727
run: uv run mkdocs build --strict
2828
- uses: actions/upload-pages-artifact@v3
2929
with:
3030
path: site/
31+
3132
docs:
3233
name: Deploy docs
3334
runs-on: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
5+
- id: ruff-check
6+
name: Lint with ruff
7+
entry: uv run ruff check --fix
8+
language: system
9+
types: [python]
10+
pass_filenames: false
11+
verbose: true
12+
13+
- id: ruff-format
14+
name: Format with ruff
15+
entry: uv run ruff format
16+
language: system
17+
types: [python]
18+
pass_filenames: false
19+
verbose: true
20+
21+
- id: mypy
22+
name: Check typing with mypy
23+
entry: uv run mypy
24+
language: system
25+
types: [python]
26+
pass_filenames: false
27+
verbose: true
28+
29+
- id: pymarkdown
30+
name: Markdownlint
31+
description: Run markdownlint on Markdown files
32+
entry: uv run pymarkdown scan
33+
language: system
34+
files: \.(md|mdown|markdown)$
35+
36+
- id: check-added-large-files
37+
name: Check for added large files
38+
entry: uv run check-added-large-files
39+
language: system
40+
41+
- id: check-toml
42+
name: Check Toml
43+
entry: uv run check-toml
44+
language: system
45+
types: [toml]
46+
47+
- id: check-yaml
48+
name: Check Yaml
49+
entry: uv run check-yaml
50+
language: system
51+
types: [yaml]
52+
exclude: ^mkdocs.yml$
53+
54+
- id: mixed-line-ending
55+
name: Check mixed line endings
56+
entry: uv run mixed-line-ending
57+
language: system
58+
types: [text]
59+
stages: [pre-commit, pre-push, manual]
60+
61+
- id: end-of-file-fixer
62+
name: Fix End of Files
63+
entry: uv run end-of-file-fixer
64+
language: system
65+
types: [text]
66+
stages: [pre-commit, pre-push, manual]
67+
68+
- id: trailing-whitespace
69+
name: Trim Trailing Whitespace
70+
entry: uv run trailing-whitespace-fixer
71+
language: system
72+
types: [text]
73+
stages: [pre-commit, pre-push, manual]
74+
75+
- id: check-merge-conflict
76+
name: Check merge conflicts
77+
entry: uv run check-merge-conflict
78+
language: system
79+
80+
- id: no-commit-to-branch
81+
name: Check not committting to main
82+
entry: uv run no-commit-to-branch
83+
language: system
84+
args: ["--branch", "main"]
85+
pass_filenames: false

RELEASING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
2. Determine the next version, following [semantic versioning](https://semver.org/)
55
3. Create a release branch: `git checkout -b release/{package}-v{version}`
66
4. Update that package's CHANGELOG with:
7-
- A new header with the new version
8-
- A new link at the bottom of the CHANGELOG for that header
7+
- A new header with the new version
8+
- A new link at the bottom of the CHANGELOG for that header
99
5. `git push -u origin`
1010
6. Once approved, merge the PR
1111
7. `git checkout main && git pull && git tag {package}/v{version} && git push {package}/v{version}`

pyproject.toml

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@ readme = "README.md"
66
requires-python = ">=3.10"
77
dependencies = [
88
"stapi-pydantic",
9+
"stapi-fastapi",
910
]
1011

1112
[dependency-groups]
1213
dev = [
14+
"pytest>=8.1.1",
15+
"pytest-coverage>=0.0",
1316
"mypy>=1.15.0",
1417
"pytest>=8.3.5",
1518
"ruff>=0.11.2",
19+
"pymarkdownlnt>=0.9.25",
20+
"pre-commit>=4.2.0",
21+
"pre-commit-hooks>=5.0.0",
1622
]
1723
docs = [
1824
"mkdocs-material>=9.6.11",
@@ -23,11 +29,61 @@ docs = [
2329
default-groups = ["dev", "docs"]
2430

2531
[tool.uv.workspace]
26-
members = ["stapi-pydantic"]
32+
members = ["stapi-pydantic", "stapi-fastapi"]
2733

2834
[tool.uv.sources]
2935
stapi-pydantic.workspace = true
36+
stapi-fastapi.workspace = true
37+
38+
[tool.ruff]
39+
line-length = 120
40+
41+
[tool.ruff.format]
42+
quote-style = 'double'
43+
44+
[tool.ruff.lint]
45+
select = [
46+
"E", # pydocstyle error
47+
"W", # pydocstyle warning
48+
"F", # Pyflakes
49+
"I", # isort
50+
"UP", # pyupgrade
51+
"C9" # mccabe complexity
52+
]
53+
54+
[tool.ruff.lint.mccabe]
55+
max-complexity = 8 # default 10
3056

3157
[tool.mypy]
3258
strict = true
33-
files = "stapi-pydantic/src/stapi_pydantic/**/*.py"
59+
files = [
60+
"stapi-pydantic/src/stapi_pydantic/**/*.py",
61+
"stapi-fastapi/src/stapi_fastapi/**/*.py"
62+
]
63+
64+
[[tool.mypy.overrides]]
65+
module = "pygeofilter.parsers.*"
66+
ignore_missing_imports = true
67+
68+
[tool.pymarkdown]
69+
plugins.md013.line_length = 120
70+
plugins.md024.enabled = false # duplicate headers in changelog
71+
72+
[tool.coverage.report]
73+
show_missing = true
74+
skip_empty = true
75+
sort = "Cover"
76+
omit = [
77+
"stapi-pydantic/tests/**/*.py",
78+
"stapi-fastapi/tests/**/*.py",
79+
]
80+
81+
[tool.pytest.ini_options]
82+
addopts="--cov=stapi-pydantic/src/stapi_pydantic --cov=stapi-fastapi/src/stapi_fastapi"
83+
filterwarnings = [
84+
"ignore:The 'app' shortcut is now deprecated.:DeprecationWarning",
85+
"ignore:Pydantic serializer warnings:UserWarning",
86+
]
87+
markers = [
88+
"mock_products",
89+
]

scripts/format

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

scripts/lint

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

0 commit comments

Comments
 (0)