Skip to content

chore: more specific types - #63

Merged
techouse merged 18 commits into
mainfrom
chore/more-specific-types
Oct 10, 2026
Merged

techouse merged 18 commits into
mainfrom
chore/more-specific-types

Conversation

@techouse

@techouse techouse commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

This pull request focuses on improving type annotations and type safety across the codebase, especially in the encoding and decoding logic of the qs_codec package. The main changes include adding more precise type hints, updating function signatures, and refining the use of generics in several modules. These changes enhance code clarity, maintainability, and compatibility with static type checkers.

Type Annotation Improvements

  • Added explicit type annotations for variables, function parameters, and return types throughout src/qs_codec/encode.py, src/qs_codec/decode.py, and related modules, increasing type safety and readability. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]

  • Updated the filter_ and side_channel parameters and attributes to use more specific generic type annotations, such as WeakKeyDictionary[t.Any, t.Any] and t.Callable[[str, t.Any], t.Any], in both function signatures and class definitions. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]

Module and Import Adjustments

  • Added from __future__ import annotations to several modules to support postponed evaluation of type annotations, which helps with forward references and improves compatibility with static type checkers. [1] [2]

Enum and Export Consistency

  • Updated __all__ definitions in enums/decode_kind.py and enums/sentinel.py to use typed tuples for consistency and type checking. [1] [2] [3]

These changes collectively improve the maintainability and robustness of the code by making type expectations explicit and reducing the risk of runtime errors due to type mismatches.

Summary by CodeRabbit

  • Chores
    • Refined type annotations across encoding, decoding, options, and utility components. Runtime behavior and encoding and decoding results are unchanged. These updates do not change the features or workflows available in the application.

… and __init_subclass__ methods for improved type safety
@techouse techouse self-assigned this Oct 10, 2026
@techouse techouse added the python Pull requests that update Python code label Oct 10, 2026
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a2528700-7aef-4439-97c1-b8867068d516

📥 Commits

Reviewing files that changed from the base of the PR and between ed181e6 and d365818.


📒 Files selected for processing (1)
  • src/qs_codec/models/overflow_dict.py

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c5a6f1da-6d63-4c7f-9d6c-cb66a35a9f39


📥 Commits

Reviewing files that changed from the base of the PR and between c2b7c2d and ed181e6.



📒 Files selected for processing (14)
  • src/qs_codec/decode.py
  • src/qs_codec/encode.py
  • src/qs_codec/enums/decode_kind.py
  • src/qs_codec/enums/sentinel.py
  • src/qs_codec/models/decode_options.py
  • src/qs_codec/models/encode_frame.py
  • src/qs_codec/models/encode_options.py
  • src/qs_codec/models/key_path_node.py
  • src/qs_codec/models/overflow_dict.py
  • src/qs_codec/models/undefined.py
  • src/qs_codec/models/weak_wrapper.py
  • src/qs_codec/utils/decode_utils.py
  • src/qs_codec/utils/encode_utils.py
  • src/qs_codec/utils/utils.py


Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.




📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request adds explicit local-variable types and refines callable, collection, and method annotations across the encoding, decoding, model, and utility modules. The summaries report no changes to encoding or decoding logic.

Changes

Type annotation updates

Layer / File(s) Summary
Encoding signatures and state annotations
src/qs_codec/encode.py, src/qs_codec/models/encode_frame.py, src/qs_codec/models/encode_options.py
Encoding filters now specify callable argument and return types. Side-channel dictionaries and local variables also receive explicit types.
Decoding and parsing annotations
src/qs_codec/decode.py, src/qs_codec/models/decode_options.py, src/qs_codec/utils/decode_utils.py
Decoder selection, parsing locals, and key-scanning locals receive explicit types.
Model contracts and utility annotations
src/qs_codec/enums/*, src/qs_codec/models/*, src/qs_codec/utils/encode_utils.py, src/qs_codec/utils/utils.py
Model methods, exported-name declarations, and utility locals receive more specific types. Utils.apply and filter annotations specify callable signatures.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other



Merge Risk: ⚪ Minimal · up to ed181

The changes are described as typing refinements with no established behavior regression. No actionable merge-blocking risk is identified; normal checks remain appropriate.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check Warning The description explains the typing changes, but it omits the required issue reference, change-type selection, testing details, and checklist responses. Add the required template sections. Include the issue reference, select the applicable change type, describe the tests and reproduction steps, and complete the checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly identifies the main change: refining type annotations across the codebase.
Docstring Coverage Passed Docstring coverage is 81.58% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 38 functions across 14 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.



✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR



🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR



  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codacy-production

codacy-production Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

🟢 Coverage 100.00% diff coverage · +0.00% coverage variation

Metric Results
Coverage variation ✅ +0.00% coverage variation (-1.00%)
Diff coverage ✅ 100.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (c2b7c2d) Report Missing Report Missing Report Missing
Head commit (d365818) 1935 (+6) 1935 (+6) 100.00% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#63) 82 82 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c2b7c2d) to head (d365818).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #63   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        22           
  Lines         1929      1935    +6     
=========================================
+ Hits          1929      1935    +6     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@techouse techouse added enhancement New feature or request and removed enhancement New feature or request labels Oct 10, 2026
@techouse
techouse merged commit fac2926 into main Oct 10, 2026
26 checks passed
@techouse
techouse deleted the chore/more-specific-types branch October 10, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant