Repository navigation
Conversation
MethodConfig["arg_schema"] was documented for POST but silently ignored; the endpoint used "schema" for both request input and response output. Resolve post_input_schema and post_response_schema before the GenericIndex class body so the decorators can reference them. When arg_schema is present it is used as the input schema; schema continues to be the response schema. When arg_schema is absent the behaviour is unchanged (schema for both). Add tests/integration/test_arg_schema.py covering: - POST arg_schema: valid input accepted, invalid secret rejected (422), missing required field rejected (422), response uses schema not arg_schema - POST without arg_schema: backwards-compatible (schema for both) - PATCH arg_schema: valid payload accepted, unknown fields rejected (422)
- pyproject.toml: ruff ^0.8.5 -> ^0.16.2; drop the UP038 ignore (rule removed) - base_roles.py: UP042 fix, BaseRoleEnum(str, enum.Enum) -> enum.StrEnum. Behaviourally inert: every path uses .value or plain-str comparison before roles reach serialisation, the sa.String(50) column, or query filters. - base_roles.pyi: stub follows, with real member values instead of plain str - docs/user-models.rst: BaseRoleEnum.MODERATOR does not exist, use USER - CONTRIBUTING.md: single bootstrap step, poetry install --sync plus pre-commit install - reformat tests/unit/test_version.py and tests/integration/test_arg_schema.py under the new formatter and RUF059
The sed calls were unchecked: a non-matching pattern exits 0 and slips past set -e, then the script printed "updated" unconditionally. tests/unit/ test_version.py runs before the bump, so it only catches the breakage on the next run. - assert the rewritten line exists (anchored on __version__ = "$NEW_VERSION") and exit 1 otherwise; the success echo now follows the assertion - drop the README badge substitution: it has matched nothing since the ?v= markers were removed in f317efd, and a broadened pattern would corrupt the sample JSON in README.md - collapse the macOS/Linux branch: [0-9][0-9]* is valid POSIX BRE under BSD and GNU sed, so only the -i argument differs - read the new version with poetry version -s instead of parsing awk field 6
Bandit had five config sources and three were dead: it only reads [tool.bandit] when passed -c pyproject.toml (no invocation did), and the root .bandit file is never discovered when the scan target is flask_more_smorest/. Only the tox env's inline -s list had any effect. The scan itself reports zero issues, and ruff's S ruleset already covers both flask_more_smorest and tests with correct per-file ignores. Removed: the dev dependency, the lint-job step, the standalone security job (build now needs [test, lint]), the tox security env, [tool.bandit], the pre-commit hook, and the .bandit file.
The package allows >=3.11,<4.0 but CI only tested 3.11 and 3.12, and local development already runs 3.14. Add 3.13 and 3.14 to the test matrix and the classifiers. mypy python_version stays at 3.11: it tracks the supported floor, not the development interpreter. Bump the actions off the deprecated Node 20 runtime: checkout v4 -> v5, setup-python v5 -> v6 (v4 in pre-commit.yml), cache v4 -> v5, upload-artifact and download-artifact v4 -> v5, codecov-action v4 -> v5. codecov-action v5 dropped the `file` input, so rename it to `files` in the same change; with fail_ci_if_error false, a bare bump would have stopped the coverage upload silently. Pin snok/install-poetry to 2.4.1 instead of `version: latest` so builds are reproducible.
poetry install --sync is deprecated in Poetry 2.x and prints a removal warning.
Honouring arg_schema for POST exposed a gap in the handler: it called new_object.update(commit=True), which only creates a row when the input schema is model-bound (load_instance=True). A plain marshmallow schema, the usual case for an explicit arg_schema, deserialises to a dict, so update() just wrote a key into that dict and the endpoint returned 200 without persisting anything. Build the model instance when the payload is a dict. The POST response schema is again passed through untouched, as GET and PATCH do, so a configured Schema instance keeps its options instead of being collapsed to its class. Tests now assert the row is persisted, and cover a model-bound arg_schema. Also sweep the docs and config left stale by this series: .github/AGENTS.md still described the removed README badge step, the deleted bandit job and a 3.11/3.12 matrix; the bump script banner repeated the same claims; the tox envlist now matches the CI matrix.
The ignores were hiding a declaration problem, not a real type conflict.
post_input_schema and post_response_schema were pre-declared as None and
assigned under a guard, so both stayed Optional; pyright cannot narrow a
captured variable inside the nested class body, and the decorators then
looked like they received None. Resolve both from
config.methods.get(POST, {}) instead, which yields non-optional types and
needs no suppression.
Narrow the payload with isinstance(new_object, dict) rather than a negative
check against the model_cls variable, which pyright cannot use for narrowing:
that one was a genuine reportCallIssue on the ** expansion.
pyright is now down to the pre-existing reportRedeclaration on the paginated
and non-paginated index handlers.
The paginated and non-paginated index handlers were two `get` definitions in one class body, which is what pyright flagged: the second declaration obscures the first. They differed only in the paginate decorator and in whether the query was limited. Keep one implementation, taking pagination_parameters as an optional argument, and compose the decorator stack instead: paginate is applied only when the blueprint has a default page size. This also drops the four suppressions on the index decorators, since index_schema_class and query_filter_schema are no longer conditionally-assigned optionals. pyright is now clean across flask_more_smorest and tests. Add coverage for the branch that had none: default_page_size=None returns every row with no pagination header, and page/page_size stay inert because they come from the filter schema rather than the paginate decorator.
The Engine event listeners are registered once on the Engine class, but the thresholds were captured from whichever app registered them first. Every later app silently inherited that first configuration, so a second app's SQLALCHEMY_SLOW_QUERY_THRESHOLD did nothing, and an app that never enabled monitoring was still monitored and still had its queries counted. Resolve the settings from the app handling each query instead, falling back to the registering app's values when there is no app context. Monitoring is now off for any app that did not opt in. This is what made test_slow_query_threshold_configurable fail intermittently in full-suite runs: a fixture registered a 0.001s threshold, so any later SELECT that took longer than a millisecond logged a slow query the test did not expect. It passed in isolation because nothing had registered first. Add two tests that fail without the fix: one app's threshold must not leak into another, and an app without monitoring must stay unmonitored.
Both checkers ran over the same code with overlapping configuration. Pyright was already a dev dependency, is the checker the stubs/ directory targets, and it caught two real errors mypy missed in this series. Keeping one is enough. Removed: the mypy dependency, [tool.mypy] and its two override tables, tests/mypy.ini, scripts/mypy.sh, the tox mypy env, and the mypy steps in CI, pre-commit and the release script. Pyright takes their place, with scripts/pyright.sh as the entry point named in AGENTS.md. Enable reportUnnecessaryTypeIgnoreComment, which replaces mypy's warn_unused_ignores. It flagged 88 dead suppressions, all removed. The remaining mypy-style comments are now rule-scoped pyright ignores: a bare "# type: ignore" suppresses everything on the line for pyright too, so leaving them would have hidden real errors. The five warnings they were masking are now explicit.
These two rules are what mypy's disallow_untyped_defs and disallow_incomplete_defs were buying, and pyright's standard mode leaves them off. Turning them on surfaced 177 sites: 43 in the package, 134 in the tests. All are fixed with real annotations; no rule was disabled and no suppression was added (the ignore count is unchanged at 62, and the one that moved did so because the formatter rewrapped its signature). Notable choices: - exceptions.py: debug context was dict[str, str | int | bool | dict | None], whose inner dict was unparameterised. It is now a recursive DebugContext alias built on Mapping/Sequence, which is covariant, so the nested dict[str, str | None] values the code actually stores still fit. - SQLAlchemySchema and SQLAlchemyAutoSchema are generic over the model type. Schemas here are built per model at runtime by create_model_schema, so the parameter is Any rather than a model that the factory cannot carry. - db.session is scoped_session[flask_sqlalchemy.session.Session], not sqlalchemy.orm.Session; the test fixtures now say so. - The db_session fixture yields None, and its annotation now says that. - Permission hooks in tests take user: Any, matching _can_read/_can_write in the library.
An arg_schema exists to accept an input shape that differs from the model, which is exactly what the documented invite-only signup does: it validates an invite_code that is not a column. Passing the deserialised dict straight to the declarative constructor raised TypeError, so the documented configuration went from silently doing nothing to returning 500. Keys the model does not define are now dropped, mirroring what marshmallow-sqlalchemy already does for a model-bound schema. The new test uses the documented shape and fails with TypeError without this change.
stubPath was "./stubs;./stubs/test_stubs". Pyright takes a single directory, so it reported "not a valid directory" and silently ignored the whole tree: every .pyi in it has been dead since it was added, including the base_roles stub this branch edited. Pointing stubPath at stubs/ made pyright resolve the package through those stubs instead of the source and produced 16 errors, because the tree is partial: there is no defaults.pyi, so the models it re-exports became Unknown. The package ships py.typed, the stubs are not in the wheel, and they duplicate an inline-typed package they had already drifted from, so they go. Also set pythonVersion = "3.11". Pyright was inferring the language level from the interpreter, so local runs checked 3.14 while CI checked 3.11 and the declared floor is 3.11.
- CHANGELOG: the Unreleased section was empty while this branch changed four user-visible behaviours, including the BaseRoleEnum string form. - docs/crud.rst: arg_schema was only shown on PATCH. Document it for POST, state that unknown fields are dropped, and name the INDEX fork that plan item 6 deferred, so the reason it is unimplemented is recorded. - database.py: the "monitoring enabled" line printed the registering app's threshold as if it were global; say which app it belongs to. - user_context.py: the cast comment referred to mypy, which is gone. - pyproject: list pyright with the other code-quality tools, not under docs.
Member
Author
|
Superseded by #42, which has the same head commit and an accurate description: this branch grew a second half (pyright replacing mypy, the stubs removal, and two library fixes found in review) after this PR was opened. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the six items tracked in the open-issues follow-up list.
66994afarg_schemafor the request input whileschemastays the response schema. INDEX is deliberately deferred: the semantics fork (verbatimarg_schemalike PATCH, versusgenerate_filter_schema(base_schema=arg_schema)) is not settled.3bb7da7BaseRoleEnumtoenum.StrEnumwith a matching stub, docs typo, contributor bootstrap.89e1d28scripts/bump_version.shfails loudly on a bad substitution.a413445Sruleset is the single security lint.6b9b539cf6d0afpoetry install --syncis deprecated in Poetry 2.x.d4a7b29Load-bearing details
codecov/codecov-actionv5 dropped thefileinput. The rename tofileslands in the same commit as the bump; withfail_ci_if_error: falsea bare bump would have stopped the coverage upload silently.arg_schemafor POST initially broke creation. A plain marshmallow schema deserialises to a dict, sonew_object.update(commit=True)wrote a key into that dict and the endpoint returned 200 while persisting nothing. The handler now builds the model instance from a dict payload, and the tests assert the row exists rather than echoing the response body. This is the configuration documented for invite-only signup.Schemainstance keeps its options.python_versionstays at 3.11: it tracks the supported floor, not the development interpreter.Salready coversflask_more_smorestandtestswith correct per-file ignores.Verification
Locally on 3.14: 395 tests pass,
scripts/mypy.sh .clean over 86 files, ruff format and check clean, pre-commit clean, both workflow files parse.What this PR run needs to confirm
publishuses Trusted Publishing and a broken hand-off would otherwise only surface at release time.