Skip to content

Add patch_env to Python workers sdk#5687

Merged
hoodmane merged 1 commit intomainfrom
hoodmane/patch-env
Dec 16, 2025
Merged

Add patch_env to Python workers sdk#5687
hoodmane merged 1 commit intomainfrom
hoodmane/patch-env

Conversation

@hoodmane
Copy link
Copy Markdown
Contributor

@hoodmane hoodmane commented Dec 12, 2025

A context manager, to be used like:

with patch_env(key1=value1, key2=value2):
    # env is patched
# env is restored

@jasnell
Copy link
Copy Markdown
Collaborator

jasnell commented Dec 12, 2025

the JS and C++ bits LGTM modulo a couple of nits. Did not look at the python bits.

@hoodmane
Copy link
Copy Markdown
Contributor Author

Thanks for the review @jasnell! I applied the changes except for moving PythonPatchedEnv to pyodide.h.

Copy link
Copy Markdown
Contributor

@ryanking13 ryanking13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay to me, but I think I don't have enough knowledge on defining a new API in workerd yet, so leaving approval to other people.

Copy link
Copy Markdown
Contributor

@ryanking13 ryanking13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I saw that James approved for the C++ and JS part, so let me approve.

@hoodmane hoodmane force-pushed the hoodmane/patch-env branch 6 times, most recently from 9119b37 to 7102718 Compare December 15, 2025 19:23
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 15, 2025

The generated output of @cloudflare/workers-types matches the snapshot in types/generated-snapshot 🎉

A context manager, to be used like:

```
with patch_env(key1=value1, key2=value2):
    # env is patched
# env is restored
```
@hoodmane hoodmane merged commit 3d8bf1e into main Dec 16, 2025
52 of 57 checks passed
@hoodmane hoodmane deleted the hoodmane/patch-env branch December 16, 2025 16:38
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