Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,7 @@ jobs:
- name: Install the Poetry that wrote poetry.lock
run: pip install "poetry==$(sed -n 's/.*generated by Poetry \([0-9.]*\).*/\1/p' poetry.lock | head -1)"
- run: poetry install --no-interaction
- run: poetry run pytest
# -X warn_default_encoding: a text read without an explicit encoding is a
# warning, and pytest.ini turns warnings into errors. On the interpreter,
# not in the job's env, so Poetry's own process stays quiet.
- run: poetry run python -X warn_default_encoding -m pytest
3 changes: 2 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ test:
# The PostgreSQL major the project targets; CI on GitHub tests the same one.
- postgres:17
script:
- poetry run pytest --junitxml=report.xml
# -X warn_default_encoding: same as the GitHub job, see its comment.
- poetry run python -X warn_default_encoding -m pytest --junitxml=report.xml
artifacts:
when: always
reports:
Expand Down
4 changes: 3 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ docs/ # setup, authentication, api, schemas, releasing, known_issue
## Common Commands
* **Start dev server**: `poetry run uvicorn basic_api.main:app --reload --app-dir src`
* **Test**: `poetry run pytest` (needs PostgreSQL; `--noconftest` plus the pure
test files runs without one)
test files runs without one). Every warning is an error (`pytest.ini`); CI
adds `-X warn_default_encoding`, so run
`poetry run python -X warn_default_encoding -m pytest` before pushing.
* **Format & lint**: `poetry run black src tests scripts && poetry run flake8 src tests scripts`
* **Type check**: `poetry run mypy` (covers `src` and `scripts`)
* **Release** (in a clone, never in the starter): `poetry run python scripts/release.py prepare minor`;
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ notes (see [docs/releasing.md](docs/releasing.md)).
`RequestBodyLimitMiddleware` answers 413 before any route runs (#13).

### Changed
- The test suite treats every warning as an error (`filterwarnings = error`
in `pytest.ini`), and both CI test jobs start the interpreter with
`-X warn_default_encoding`. A deprecation in this code or in a dependency,
or a text read without an explicit encoding, now fails CI instead of
scrolling past in the summary; the suite was already clean under both, with
dependencies included (#24).
- Python 3.15 idioms. Read-only module constants are `frozendict`
(`_SECRET_MINIMUM_BYTES`, `_TAKEN_MESSAGES`, `_DESCRIPTIONS`, the release
script's `SECTIONS`); generic aliases come from `collections.abc` with the
Expand Down
12 changes: 10 additions & 2 deletions docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,16 @@ poetry run pytest --noconftest tests/test_auth_units.py tests/test_user_schemas.
tests/test_logging_config.py tests/test_request_id.py tests/test_release_script.py
```

Deprecation warnings are not silenced; a new one in the summary is information,
not noise.
Every warning is an error (`filterwarnings = error` in `pytest.ini`): a
deprecation in this code or in a dependency fails the run instead of scrolling
past in the summary. Fix it, update the dependency, or record it in
[Known Issues](known_issues.md) with a narrow ignore. CI also starts the
interpreter with `-X warn_default_encoding`, so a text read without an explicit
encoding fails there; the same run locally is:

```bash
poetry run python -X warn_default_encoding -m pytest
```

## Code quality

Expand Down
7 changes: 5 additions & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ addopts = -ra -q
testpaths = tests
pythonpath = src
python_files = test_*.py
# No warning filters: a deprecation in our code or a dependency stays visible
# in the summary and is dealt with (or recorded in docs/known_issues.md).
# Every warning is an error: a deprecation in our code or in a dependency fails
# the run instead of scrolling past in the summary. Fix it, update the
# dependency, or record it in docs/known_issues.md with a narrow ignore below.
filterwarnings =
error
asyncio_mode = auto
asyncio_default_fixture_loop_scope = function
Loading