docs: correct docstrings and guides that disagree with the code - #142
Merged
Merged
Conversation
Fixes the items collected in the 0.3.6 review: sliding_threshold described the opposite of what the code does, several cache() arguments were misdescribed, the per-user key_builder example set private=True (which bypasses the backend), the state quick start let StateDataError become a 500, session docs pointed at the deprecated SessionMiddleware, the monitoring routes claimed to count hits, and Memcached docstrings promised matching it cannot do. Closes #108
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 #108
Documentation and docstrings only. The one runtime string that changes is the
get_session_manager500 detail, and the existing test still matches its prefix. Behaviour is unchanged.Changes, per item in #108
SessionConfig.sliding_threshold: the description now says the session renews once less than this fraction ofsession_ttlremains. It used to describe the opposite.cache()docstring: each argument is described by what the code does.no_cachestill stores entries and still answers 304. Withno_cachethe header carries onlyno-cache(plusmust-revalidate), andttl,stale,public/privateandimmutableare left out.stale_ttlonly sets thestale-while-revalidateorstale-if-errorvalue.privatebypasses the backend.ttldoubles asmax-age.no_storetakes precedence over the other options.Raises:section lists the three decoration-timeCacheXErrors.docs/HTTP_CACHING.md, authenticated endpoints, option 2:key_builderexample dropsprivate=True, which bypassed the backend so the key builder was never used.private, the response ismax-age=60, which shared caches may store. The example therefore setsVary: Authorizationthrough the injectedResponse, and a note says when to fall back to option 1.Varyheader is replayed on a cache hit.Request/Response.add_routes()/get_cached_hits:CacheHit*model docstrings say the*_hitsfields count entries.Example:block is fenced, and I checked that it renders as a code block in the API reference.BaseCacheBackend.delete_many: only memory and Redis batch; Memcached keeps the per-key loop.clear_path/clear():clear_pathis documented as deleting only the exact key.clear()'s docstring and itsRuntimeWarningno longer suggestclear_path()for clearing a namespace, which Memcached cannot do. They point todelete()/delete_many()for known keys instead.get_session_manager500 message nameFastAPICacheXSessionMiddleware.SessionManager._iter_sessions: says that the built-in Memcached backend returns[]with a warning, while a custom backend may raiseNotImplementedError.docs/STATE.mdquick start: catchesStateError, so a malformed state is a 400 rather than a 500.CLAUDE.md/docs/DEVELOPMENT.md: describe the actual convention for forward references. Most modules use quoted annotations withTYPE_CHECKINGimports; only 2 of 33 modules usefrom __future__ import annotations.CacheManager.__init__: documentsBackendNotFoundError.StateManager.__init__had the same gap and is fixed too.The CHANGELOG has an entry under Fixed.
Verification
zensical build --strictall pass. The commit's pre-commit hooks pass as well.