Skip to content

Annotate the serializable decorators and fix the error type of Result - #59

Merged
drhagen merged 2 commits into
drhagen:masterfrom
renan-r-santos:typed-decorators
Aug 2, 2026
Merged

drhagen merged 2 commits into
drhagen:masterfrom
renan-r-santos:typed-decorators

Conversation

@renan-r-santos

Copy link
Copy Markdown
Contributor

This PR fixes two typing gaps that make serialite consumers lose type information. There is no runtime behavior change.

First, serializable and abstract_serializable had no annotations. Type checkers therefore treat every decorated class as passing through an untyped decorator and degrade or flag it. Both decorators now declare the identity signature (cls: type[T]) -> type[T], which is what checkers already assume. flexible_decorator is typed as (dec: F) -> F and casts its wrapper, so the inner signature is preserved through it.

Second, in _result.py the annotated alias Failure: type[result.Failure[Errors]] was immediately overwritten by Failure = result.Failure, so the Errors parameterization was lost. As a result, Result[T].failure() evaluated to Any instead of Errors. The plain class assignment is required because class patterns like case Failure(...) need the actual class at runtime. The fix keeps the plain re-export and moves the parameterization into the alias.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.70%. Comparing base (3aad53f) to head (7d8bee6).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #59      +/-   ##
==========================================
- Coverage   92.71%   92.70%   -0.01%     
==========================================
  Files          35       35              
  Lines        1564     1563       -1     
  Branches      236      236              
==========================================
- Hits         1450     1449       -1     
  Misses         49       49              
  Partials       65       65              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@drhagen
drhagen merged commit fd10f8b into drhagen:master Aug 2, 2026
6 checks passed
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.

3 participants