Skip to content

feat: deprecate the unused CacheError - #224

Merged
allen0099 merged 1 commit into
masterfrom
feat/deprecate-cache-error
Sep 26, 2026
Merged

allen0099 merged 1 commit into
masterfrom
feat/deprecate-cache-error

Conversation

@allen0099

Copy link
Copy Markdown
Owner

Closes #163. Part of #113. Removal is tracked in #130 (0.4.0).

fastapi_cachex.exceptions.CacheError is never raised anywhere in the package.

  • The class is renamed to the private _CacheError (with __name__/__qualname__ kept as CacheError) and served through a module-level __getattr__ (PEP 562). Both exceptions.CacheError and from fastapi_cachex.exceptions import CacheError emit a DeprecationWarning that points at the caller's line (stacklevel=2). It is still a CacheXError subclass, so except CacheError keeps working.
  • A TYPE_CHECKING alias keeps CacheError visible to type checkers.
  • import fastapi_cachex does not trigger the warning (checked with -W error::DeprecationWarning).
  • The API reference no longer lists the class, so docs/api/types.md gets a short deprecation note.
  • CHANGELOG: new ### Deprecated entry. It also removes the blank line between the two existing Deprecated entries, to match the rest of the file.

Tests

New tests/test_exceptions.py: the warning on attribute access (including the caller's filename), on from ... import, and AttributeError for unknown names. Mutation checks: removing the warning fails only the two warning tests; stacklevel=1 fails only the filename test. Full suite, ruff, mypy --strict, the changelog format test and both --strict --clean docs builds pass.

fastapi_cachex.exceptions.CacheError is never raised. Accessing or
importing it now emits a DeprecationWarning pointing at the caller; the
class itself is unchanged, so except CacheError keeps working until it
is removed in 0.4.0 (#130).

Closes #163
@allen0099
allen0099 merged commit d34be84 into master Sep 26, 2026
11 checks passed
@allen0099
allen0099 deleted the feat/deprecate-cache-error branch September 26, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate the unused CacheError

1 participant