You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by er...@apache.org on 2025/05/12 19:14:11 UTC

(opendal) 01/05: chore(dev): expands type hints generator iteration

This is an automated email from the ASF dual-hosted git repository.

erickguan pushed a commit to branch docs-service-website
in repository https://gitbox.apache.org/repos/asf/opendal.git

commit 522d66c81f26a133c66ddab710750d0967b8ad41
Author: Erick Guan <29...@users.noreply.github.com>
AuthorDate: Sun May 11 15:41:32 2025 +0200

    chore(dev): expands type hints generator iteration
    
    Issue 5463 discussed a future improvement to type hints.
---
 dev/src/generate/python.j2 | 8 ++++----
 dev/src/generate/python.rs | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/dev/src/generate/python.j2 b/dev/src/generate/python.j2
index 25e6daa2d..40b03b3cb 100644
--- a/dev/src/generate/python.j2
+++ b/dev/src/generate/python.j2
@@ -44,16 +44,16 @@ class _Base:
     The services list here is support by opendal pypi wheel.
     """
 
-{% for srv in srvs %}
+{% for name, service in services|items %}
     @overload
     def __init__(
         self,
-        scheme: Literal["{{srv}}"],
+        scheme: Literal["{{name}}"],
         /,
-    {%- if srvs[srv].config -%}
+    {%- if service.config -%}
         *,
     {%- endif %}
-    {%- for field in srvs[srv].config -%}
+    {%- for field in service.config -%}
         {% if field.deprecated %}
         # deprecated: {{field.deprecated["note"]}}
         {%- endif %}
diff --git a/dev/src/generate/python.rs b/dev/src/generate/python.rs
index 0e852ed0c..79add9634 100644
--- a/dev/src/generate/python.rs
+++ b/dev/src/generate/python.rs
@@ -31,14 +31,14 @@ fn enabled_service(srv: &str) -> bool {
 }
 
 pub fn generate(workspace_dir: PathBuf, services: Services) -> Result<()> {
-    let srvs = sorted_services(services, enabled_service);
+    let services = sorted_services(services, enabled_service);
     let mut env = Environment::new();
     env.add_template("python", include_str!("python.j2"))?;
     env.add_function("make_python_type", make_python_type);
-    let tmpl = env.get_template("python")?;
+    let template = env.get_template("python")?;
 
     let output = workspace_dir.join("bindings/python/python/opendal/__base.pyi");
-    fs::write(output, tmpl.render(context! { srvs => srvs })?)?;
+    fs::write(output, template.render(context! { services => services })?)?;
     Ok(())
 }