chitralverma opened a new pull request, #9332:
URL: https://github.com/apache/opendal/pull/9332

   # Which issue does this PR close?
   
   Part of #9321 (tracker #9320).
   
   # Rationale for this change
   
   On #9320, Xuanwo suggested starting with one options struct, so this PR 
generates only the Python `ListOptions` from `core/core/src/types/options.rs` 
through the shared parser in `dev/src/generate/core_options.rs`. It follows the 
Node.js `ListOptions` pilot (#9322) and stays a draft until that pattern lands. 
It exposes no new option and leaves every other Python options class 
hand-written.
   
   # What changes are included in this PR?
   
   - `dev/src/generate/python.rs` adds a `GENERATED_OPTIONS` table with the 
five existing `ListOptions` keyword arguments, their core kinds, and their 
docstrings. The generator checks the table against the parsed core struct: a 
missing field, a changed kind, a duplicate field, or a field the core parser 
skips fails generation. It then renders 
`bindings/python/src/options/generated.rs` from 
`dev/src/generate/python/options_rs.j2`. That file holds the `#[pyclass]`, its 
`FromPyObject` impl, and a conversion to core that names every core field. A 
core field the table does not list, such as `glob`, keeps its default.
   - `bindings/python/src/options.rs` re-exports the generated `ListOptions` 
from a child module, so `crate::ListOptions` and the `opendal` module export 
are unchanged.
   - `options.py` takes `ListKwargs` from the table and the other TypedDicts 
from the hand-written structs, as before. `OPTIONS_PY_ORDER` keeps the class 
order. `dev/src/generate/options.rs` stays; its test no longer expects 
`ListOptions` among the hand-written structs.
   - New tests in `dev/src/generate/python.rs` compare against literals copied 
from main:
     - `ListOptions` fields, types, docstrings, extraction, and conversion. An 
explicit `limit`, including `0`, passes through to core, and an omitted flag is 
`false`.
     - The `ListKwargs` block and the class order of `options.py`.
     - The keyword arguments of `Operator.list`, `Operator.scan`, 
`AsyncOperator.list`, and `AsyncOperator.scan`, parsed from `operator.rs`, 
against main and against the table.
     - A new core field renders as a default and leaves `options.py` unchanged. 
Core drift fails generation.
   
   # Are there any user-facing changes?
   
   None. Evidence on this head:
   
   - The generated `ListOptions` differs from main's hand-written code in one 
line: `..Default::default()` became `glob: None`.
   - `just stub-gen` leaves `options.py`, `_opendal.pyi`, and the other stubs 
byte-identical. Every `ci_odev.yml` generator plus `cargo fmt` leaves `git diff 
--exit-code` clean.
   - One probe script exercised method signatures, class docs, TypedDicts, and 
calls with explicit `limit=0`, `False` flags, `None`, and wrong types, sync and 
async, on memory and fs. It printed identical output against builds of main and 
this head.
   - `tests/test_sync_list.py`, `tests/test_async_list.py`, and the full suite 
give the same counts on both builds: list suites 4 passed and 2 skipped on 
memory, 6 passed on fs; full suite 477 passed and 90 skipped on memory, 526 
passed and 41 skipped on fs.
   - The `check_generated`, Python `lint`, and Python `stubs` job steps, plus 
the memory and fs suites, also pass in an Ubuntu 24.04 container.
   - Mutations: 11 scratch edits to the table, the lowering, the template, the 
`options.py` order, and the `operator.rs` signatures each fail at least one new 
test. Adding two fields to core `ListOptions` adds only their two defaults to 
the generated conversion, and every new test still passes.
   
   # Breaking changes
   
   None.
   
   # AI Usage Statement
   
   - **Harness:** Claude Code via T3 Code. **Model:** Claude Opus 5.5. 
**Effort:** xhigh. **Role:** Implemented the generator, template, and tests; 
ran the surface diff, mutation checks, main-versus-head probe, and the local 
and Linux CI steps; drafted this description. The author reviews every change 
and claim.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to