Skip to content

Conversation

@j03-dev
Copy link
Owner

@j03-dev j03-dev commented Jan 9, 2026

  • chore: use rust 2024 edition
  • just refactoring the code
  • improve extend_exception macros
  • set context to be empty dict as default instead of Optional
  • none important change, the cors headers becom a vec of string
  • update stub gen file
  • remplace oncel and lazy by pyoncelock gil compatible
  • Update oxapy/init.py
  • remove once cell deps, use pyoncelock for global static
  • fix: potential security issue with path
  • not leak server directory
  • add secure join to fix security issue with static file handler
  • use normpath instead of abspath
  • improve securite to avoid path traveral
  • replace wrap struct to function

Summary by CodeRabbit

  • Refactor
    • Internal modernization of type handling and code structure across core modules to improve maintainability and type safety. No changes to user-facing functionality or behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR upgrades PyO3 bindings from Py<PyAny> to Bound<'_, PyAny> throughout the codebase, introduces explicit Python GIL tokens to multiple functions, and replaces wrapper-based type conversions with direct helper functions (from_pydict2rstruct, from_rstruct2pydict). JSON serialization is refactored to use direct orjson calls.

Changes

Cohort / File(s) Summary
Type Annotation Updates
oxapy/__init__.py
Added type-ignore comments (ty:ignore) to suppress unresolved reference errors in static analysis; no behavioral changes.
Core JSON Module Refactoring
src/json.rs
Introduced orjson(py) helper; replaced dumps/loads signatures to accept Bound<PyAny>/Bound<PyDict> and explicit Python tokens; removed Wrap<T> newtype and added from_pydict2rstruct<T> and from_rstruct2pydict<T> public helpers for conversions via JSON serialization.
Response Conversion Updates
src/into_response.rs
Updated TryFrom implementations from Py<PyAny> to Bound<'_, PyAny> in both single-value and tuple-based variants; adjusted JSON dumping calls to pass both the bound object and its Python reference.
JWT Verification
src/jwt.rs
Updated verify_token to accept Python<'_> parameter and return PyDict; replaced Wrap-based conversions with new json::from_rstruct2pydict helper.
Request Body Parsing
src/request.rs
Updated json() method signature to accept Python<'_> parameter; pass py token to json::loads call.
Response JSON Serialization
src/response.rs
Updated from_json to pass Python object and its reference to json::dumps.
Serializer Validation
src/serializer/mod.rs
Added Python<'_> parameter to is_valid method; updated JSON loading calls and replaced dict-to-JSON conversion with json::from_pydict2rstruct.
Templating Context Conversion
src/templating/minijinja.rs, src/templating/tera.rs
Replaced context.try_into() with json::from_pydict2rstruct(&context, context.py()) for PyDict deserialization to Rust HashMap.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested labels

new version

Poem

🐰 From Py to Bound, we leap and bound,
With GIL tokens held up high,
Wrap bows out, conversions shout,
PyO3's modern way—no lie!
Refactor done, the work is fun! 🎉

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 23a8a40 and cb24c38.

📒 Files selected for processing (9)
  • oxapy/__init__.py
  • src/into_response.rs
  • src/json.rs
  • src/jwt.rs
  • src/request.rs
  • src/response.rs
  • src/serializer/mod.rs
  • src/templating/minijinja.rs
  • src/templating/tera.rs

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 and usage tips.

@j03-dev j03-dev merged commit 07f2e0d into main Jan 9, 2026
15 of 16 checks passed
@j03-dev j03-dev deleted the remove/python_gil_from_json_mod branch January 9, 2026 13:40
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.

2 participants