Repository navigation
feat(routes)!: require dependencies in add_routes and hide previews by default - #413
Merged
Merged
Conversation
…y default The monitoring routes have no authentication of their own. add_routes() now takes dependencies as a required keyword-only argument: pass a guard, or dependencies=[] to mount the routes unguarded on purpose. Passing None raises TypeError. include_content_preview is keyword-only and defaults to False. The 0.3.9 UserWarning is removed. BREAKING CHANGE: add_routes() without dependencies, with dependencies=None, or with dependencies or include_content_preview passed by position raises TypeError. /cached-records reports content_preview as null unless include_content_preview=True is passed. Closes #298
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.
Closes #298. The 0.3.9 warning was #301.
Changes
add_routes(app, prefix="", include_in_schema=False, *, dependencies, include_content_preview=False):dependenciesis required and keyword-only. Pass a guard, ordependencies=[]to mount the routes unguarded on purpose.NoneraisesTypeError, with a message that names both fixes. Leavingdependenciesout gets Python's own "missing required keyword-only argument" error. Type checkers flag both.include_content_previewdefaults toFalse. It also becomes keyword-only, because it followsdependencies.prefixandinclude_in_schemacan still be passed by position.UserWarningis removed.docs/andi18n/zh-TW/docs/:HTTP_CACHING: the example showsinclude_content_preview=True, and the warning box states thatdependenciesis required.MIGRATING_0_4:TypeError;dependencies;dependencieswas left out.changelog.d/298.changed.md.Tests
TestDependenciesRequiredcovers:dependenciesout;None, which raises and mounts no route;[], which mounts the routes unguarded;prefixandinclude_in_schemapassed by position.False.Nonecheck;True;dependenciesa default.mypy(strict package, tests, scripts), pre-commit, both strict docs builds andtox -e lowestpass.